Edgewall Software
Modify

Ticket #4729 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

Trac broken for Python 2.3: tee not in itertools

Reported by: anonymous Owned by: mgood
Priority: high Milestone: 0.11
Component: general Version: devel
Severity: critical Keywords: python23
Cc: tjb@…
Release Notes:
API Changes:

Description

Traceback (most recent call last):
  File "C:\Python23\Scripts\trac-admin", line 21, in ?
    from trac.admin.console import run
  File "C:\Python23\Lib\site-packages\trac\admin\console.py", line 28, in ?
    from trac import perm, util, db_default
  File "C:\Python23\Lib\site-packages\trac\perm.py", line 21, in ?
    from trac.config import ExtensionOption
  File "C:\Python23\Lib\site-packages\trac\config.py", line 26, in ?
    from trac.util import sorted
  File "C:\Python23\Lib\site-packages\trac\util\__init__.py", line 28, in ?
    from itertools import tee, izip
ImportError: cannot import name tee

see also: http://code.djangoproject.com/browser/django/trunk/django/utils/itercompat.py?rev=4084

Attachments

Change History

comment:1 Changed 5 years ago by anonymous

  • Cc tjb@… added

comment:2 Changed 5 years ago by mgood

  • Milestone set to 0.11
  • Owner changed from jonas to mgood
  • Status changed from new to assigned

Right, thanks for the reminder.

BTW itertools provides example implementations of the methods in the documentation, which is where Django got that from.

comment:3 Changed 5 years ago by mgood

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in r4776

comment:4 Changed 5 years ago by tjb@…

I applied this, and hit a separate problem, at line 97 in source:/trunk/trac/util/compat.py@4776

  File "/usr/lib/python2.3/site-packages/trac/util/compat.py", line 97 in gen
    for i in count():
NameError: global name 'count' is not defined

I am trying to find out where count() should come from.

comment:5 Changed 5 years ago by tjb@…

The following change works for me...

try:
    from itertools import tee
except ImportError:
# Need to import count!
    from itertools import count
    def tee(iterable):
        def gen(next, data={}, cnt=[0]):
            for i in count():
                if i == cnt[0]:
                    item = data[i] = next()
                    cnt[0] += 1
                else:
                    item = data.pop(i)
                yield item
        it = iter(iterable)
        return (gen(it.next), gen(it.next))

and r4776 runs correctly now.

comment:6 Changed 5 years ago by cboos

  • Keywords python23 added
  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:7 Changed 5 years ago by mgood

  • Resolution set to fixed
  • Status changed from reopened to closed

This was fixed by thatch in r4805.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from mgood. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.