[Checkins] SVN: zope.app.undo/branches/nikhil_n-py25/src/zope/app/undo/__init__.py made zope.app.undo work with Python 2.5

Benji York benji at zope.com
Sat Jul 7 09:08:48 EDT 2007


nikhil n wrote:
> Log message for revision 77570:
>   made zope.app.undo work with Python 2.5

Correct me if I'm wrong, but it looks like __eq__ below could be changed 
to just

     def __eq__(self, other):
         return other and unicode(other).startswith(self)

(Not sure if the call to unicode is even needed, but I don't know what 
this code is really doing.)

> Changed:
>   U   zope.app.undo/branches/nikhil_n-py25/src/zope/app/undo/__init__.py
> 
> -=-
> Modified: zope.app.undo/branches/nikhil_n-py25/src/zope/app/undo/__init__.py
> ===================================================================
> --- zope.app.undo/branches/nikhil_n-py25/src/zope/app/undo/__init__.py	2007-07-07 12:02:04 UTC (rev 77569)
> +++ zope.app.undo/branches/nikhil_n-py25/src/zope/app/undo/__init__.py	2007-07-07 12:13:15 UTC (rev 77570)
> @@ -83,9 +83,14 @@
>      False
>      """
>      def __eq__(self, other):
> -        if other and unicode(other[:len(self)]).__eq__(self) == 1:
> -            return True
> -        return False
> +        try:
> +            if other and unicode(other[:len(self)]).__cmp__(self) == 1:
> +                return True
> +            return False
> +        except AttributeError:
> +            if other and unicode(other[:len(self)]).__eq__(self) == 1:
> +                return True
> +            return False
>  
>      def __ne__(self, other):
>          return not self.__eq__(other)
> 
> _______________________________________________
> Checkins mailing list
> Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/checkins


-- 
Benji York
Senior Software Engineer
Zope Corporation


More information about the Checkins mailing list