On Mon, Feb 6, 2012 at 6:49 PM, Terry Brown <[email protected]> wrote:

> What does 3.x do that 2.x doesn't?

Here is the code that works on 3.x and fails on 2.x::

    def _checkKeyType(self,key):

        # These fail on Python 2.x for strings.
        if g.isPython3:
            assert key.__class__ ==
self.keyType,self._reportTypeError(key,self.keyType)

    def _checkValType(self,val):

        # This doesn't fail, either on Python 2.x or 3.x.
        assert val.__class__ ==
self.valType,self._reportTypeError(val,self.valType)

    def _reportTypeError(self,obj,objType):

        return 'dict: %s expected %s got %s' % (
            self._name,obj.__class__.__name__,objType.__name__)

On Python 2.x, the messages are: expected x, got x, which isn't too helpful :-)

In fact, the problem is a distinction between string and unicode.
I've attempted to vary the args to the ctor which sets keyType, but so
far to no avail.  Perhaps a wrapped string would actually work...

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to