Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

Last modified 4 years ago

#4729 closed defect (fixed)

Trac broken for Python 2.3: tee not in itertools

Reported by: anonymous Owned by: Matthew Good
Priority: high Milestone: 0.11
Component: general Version: devel
Severity: critical Keywords: python23
Cc: tjb@… Branch:
Release Notes:
API Changes:
Internal 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 (0)

Change History (7)

comment:1 by anonymous, 17 years ago

Cc: tjb@… added

comment:2 by Matthew Good, 17 years ago

Milestone: 0.11
Owner: changed from Jonas Borgström to Matthew Good
Status: newassigned

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 by Matthew Good, 17 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r4776

comment:4 by tjb@…, 17 years ago

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 by tjb@…, 17 years ago

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 by Christian Boos, 17 years ago

Keywords: python23 added
Resolution: fixed
Status: closedreopened

comment:7 by Matthew Good, 17 years ago

Resolution: fixed
Status: reopenedclosed

This was fixed by thatch in r4805.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Matthew Good.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Matthew Good to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.