Modify ↓
#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 , 19 years ago
| Cc: | added |
|---|
comment:2 by , 19 years ago
| Milestone: | → 0.11 |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:4 by , 19 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 , 19 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 , 19 years ago
| Keywords: | python23 added |
|---|---|
| Resolution: | fixed |
| Status: | closed → reopened |
comment:7 by , 19 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
This was fixed by thatch in r4805.
Note:
See TracTickets
for help on using tickets.



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