#35 UID generation bug for builtin __new__ methods

closed-fixed
Edward Loper
inspection (59)
5
2004-02-04
2004-02-01
Anonymous
No

Due to the peculiar behaviour of the builtin __new__
method (it being some sort of class method), the UID
generation for __builtin__.object.__new__ returns a UID
object for __builtin__.type.__new__, leading to a
warning about __new__ overriding
itself.

This patch fixes the problem (diffed from 1.44, but
applies cleanly to 1.49 as well). Should you need to
contact me, my email address is: karsten dot sperling at
stud dot uni-karlsruhe dot de.

--- uid.py.orig Tue Jul 22 14:55:58 2003
+++ uid.py Thu Jan 22 19:35:24 2004
@@ -490,7 +490,11 @@
self._cls = ObjectUID(obj.im_class)
elif (type(obj) is _BuiltinMethodType and
obj.__self__ is not None):
- self._cls = ObjectUID(type(obj.__self__))
+ if obj.__name__ == '__new__':
+ # __new__ is a class method of sorts
+ self._cls = ObjectUID(obj.__self__)
+ else:
+ self._cls = ObjectUID(type(obj.__self__))
elif type(obj) in (_WrapperDescriptorType,
_MethodDescriptorType):
self._cls = ObjectUID(obj.__objclass__)
else:

Discussion

  • Edward Loper
    Edward Loper
    2004-02-04

    Logged In: YES
    user_id=195958

    Applied & commited to cvs, 2/4/2004

     
  • Edward Loper
    Edward Loper
    2004-02-04

    • status: open --> closed-fixed