Commit da55c954 authored by Stefan Behnel's avatar Stefan Behnel

disable compile time error in favour of a runtime error as it might be too...

disable compile time error in favour of a runtime error as it might be too strict and break working code
parent c7f4ce39
...@@ -1062,10 +1062,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -1062,10 +1062,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
# otherwise, we know it's a type and we know it's the same # otherwise, we know it's a type and we know it's the same
# type for both - that should do # type for both - that should do
elif type_arg.type_entry != obj.type_entry: elif type_arg.type_entry != obj.type_entry:
# different types - do what CPython does at runtime # different types - may or may not lead to an error 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))
return node return node
# FIXME: we could potentially look up the actual tp_new C method # FIXME: we could potentially look up the actual tp_new C method
......
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__()
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment