# otherwise, we know it's a type and we know it's the same
# type for both - that should do
elif type_arg.type_entry != obj.type_entry:
- # different types - do what CPython does at runtime
- error(type_arg.pos, "%s.__new__(%s) is not safe, use %s.__new__()" %
- (obj.type_entry.name, type_arg.type_entry.name,
- type_arg.type_entry.name))
+ # different types - may or may not lead to an error at runtime
return node
# FIXME: we could potentially look up the actual tp_new C method
+++ /dev/null
-
-cdef class MyType:
- def __init__(self):
- print "INIT"
-
-cdef class MySubType(MyType):
- def __init__(self):
- print "INIT"
-
-cdef class MyOtherType:
- def __init__(self):
- print "INIT"
-
-def make_new():
- m = MyType.__new__(MyType)
- m = MyOtherType.__new__(MyOtherType)
- return m
-
-def make_new_error():
- m = MySubType.__new__(MyType)
- m = MyOtherType.__new__(MyType)
- m = MyOtherType.__new__(MySubType)
- return m
-
-_ERRORS = """
-20:32: MySubType.__new__(MyType) is not safe, use MyType.__new__()
-21:34: MyOtherType.__new__(MyType) is not safe, use MyType.__new__()
-22:37: MyOtherType.__new__(MySubType) is not safe, use MySubType.__new__()
-"""