From: Stefan Behnel Date: Sun, 1 Nov 2009 14:16:58 +0000 (+0100) Subject: disable compile time error in favour of a runtime error as it might be too strict... X-Git-Tag: 0.12.alpha0~8^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=da55c954ac4427174b35631cf024f6a3dfd373d0;p=cython.git disable compile time error in favour of a runtime error as it might be too strict and break working code --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 53ab9fa3..853bde14 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -1062,10 +1062,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): # 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 diff --git a/tests/errors/tp_new_errors.pyx b/tests/errors/tp_new_errors.pyx deleted file mode 100644 index 05b56159..00000000 --- a/tests/errors/tp_new_errors.pyx +++ /dev/null @@ -1,29 +0,0 @@ - -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__() -"""