Edgewall Software

Opened 6 years ago

Closed 6 years ago

#324 closed defect (fixed)

Test fails for Genshi-0.5.1 and Python 2.6.2

Reported by: neurogeek@… Owned by: cmlenz
Priority: trivial Milestone: 0.6
Component: General Version: 0.5.1
Keywords: Cc: lmacken@…


Hello there,

When running python setup.py test in Genshi-0.5.1 using python-2.6.2, I get a test failed for genshi.template.eval.Undefined in here:

"""Represents a reference to an undefined variable.
227	    >>> foo = Undefined('foo')
228	    >>> bool(foo)
229	    False
230	    >>> list(foo) -----> This line fail test
231	    []
232	    >>> print foo
233	    undefined


Attachments (1)

python-genshi-0.5.1-py2.6.2-length_hint.patch (492 bytes) - added by lmacken@… 6 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 6 years ago by lmacken@…

  • Cc lmacken@… added

When tweaking the class a little and running the tests::

    Failed example: list(foo)
    Expected: []

    Failed example: list(foo)
    Expected: []

Since the Undefined class overloads sets __getattr__ = _die, this causes some unexpected behavior on Python 2.6.2

I'm thinking that this behavior was introduced in: http://bugs.python.org/issue1242657 Another example of this behavior can be found in the test case that came along with it: http://svn.python.org/view/python/trunk/Lib/test/test_iterlen.py?r1=69227&r2=69226&pathrev=69227

I threw together the following patch for Fedora that gets the test suite running again:

--- genshi/template/eval.py.orig	2009-09-11 17:09:13.589445262 -0400
+++ genshi/template/eval.py	2009-09-11 17:11:17.818691489 -0400
@@ -279,6 +279,10 @@
         raise UndefinedError(self._name, self._owner)
     __call__ = __getattr__ = __getitem__ = _die
+    # Hack around some behavior introduced in Python 2.6.2
+    # http://genshi.edgewall.org/ticket/324
+    __length_hint__ = None
 class LookupBase(object):
     """Abstract base class for variable lookup implementations."""

Changed 6 years ago by lmacken@…


comment:2 Changed 6 years ago by cmlenz

  • Milestone changed from 0.6 to 0.6.1

comment:3 Changed 6 years ago by rblank

Another (much less elegant) patch is in comment:6:ticket:370.

comment:4 Changed 6 years ago by cmlenz

  • Milestone changed from 0.6.1 to 0.6
  • Status changed from new to assigned

Issue raised again in #370.

comment:5 Changed 6 years ago by cmlenz

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

Applied in [1101]. Thanks and sorry for the wait!

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.