Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #321 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

New Identity predicates from r400 fail on Python 2.3

Reported by: Robin.Munn@… Owned by: anonymous
Priority: normal Milestone: 0.9
Component: Identity Version:
Severity: normal Keywords:
Cc:

Description

The new Identity predicates in r400 are very cool, but they fail to work in Python 2.3 because of using generator expressions, which are new in 2.4:

Traceback (most recent call last):
 File "/home/rmunn/opt/bin/tg-admin", line 7, in ?
   sys.exit(
 File "/home/rmunn/opt/lib/python2.3/site-packages/setuptools-0.6a8-py2.3.egg/pkg_resources.py",
line 236, in load_entry_point
   return get_distribution(dist).load_entry_point(group, name)
 File "/home/rmunn/opt/lib/python2.3/site-packages/setuptools-0.6a8-py2.3.egg/pkg_resources.py",
line 1892, in load_entry_point
   return ep.load()
 File "/home/rmunn/opt/lib/python2.3/site-packages/setuptools-0.6a8-py2.3.egg/pkg_resources.py",
line 1625, in load
   entry = __import__(self.module_name, globals(),globals(), ['__name__'])
 File "/home/rmunn/dl/turbogears/turbogears/__init__.py", line 14, in ?
   from turbogears import controllers
 File "/home/rmunn/dl/turbogears/turbogears/controllers.py", line 12, in ?
   import view
 File "/home/rmunn/dl/turbogears/turbogears/view.py", line 13, in ?
   import identity
 File "/home/rmunn/dl/turbogears/turbogears/identity/__init__.py",
line 113, in ?
   from turbogears.identity.conditions import *
 File "/home/rmunn/dl/turbogears/turbogears/identity/conditions.py", line 93
   group_predicates= (in_group(g) for g in groups)
                                    ^
SyntaxError: invalid syntax

The solution is to bypass the syntactic sugar and replace each occurrence with something equivalent like the following (warning: code written in email client, not tested):

def group_predicates(groups):
   for g in groups:
       yield in_group(g)

I count at least 5 places where this change would have to be made:

  • identity/conditions.py, line 93
  • identity/conditions.py, line 105
  • identity/conditions.py, line 147
  • identity/conditions.py, line 159
  • identity/conditions.py, line 216

There may be others I didn't spot. Line numbers reference r435 and may be different if you're looking at a different revision.

Change History

comment:1 Changed 13 years ago by anonymous

  • Milestone set to 0.9

comment:2 Changed 13 years ago by Jeff Watkins

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

I now use list composition instead of generators.

Note: See TracTickets for help on using tickets.