import gc; gc.collect()
vereq(hasattr(c, 'attr'), False)
+import warnings
+
def test_init():
# SF 1155938
class Foo(object):
def __init__(self):
return 10
+
+ oldfilters = warnings.filters
+ warnings.filterwarnings("error", category=RuntimeWarning)
try:
Foo()
- except TypeError:
+ except RuntimeWarning:
pass
else:
raise TestFailed, "did not test __init__() for None return"
+ warnings.filters = oldfilters
def test_main():
if (res == NULL)
return -1;
if (res != Py_None) {
- PyErr_SetString(PyExc_TypeError,
- "__init__() should return None");
- Py_DECREF(res);
- return -1;
+ if (PyErr_Warn(PyExc_RuntimeWarning,
+ "__init__() should return None") == -1) {
+ Py_DECREF(res);
+ return -1;
+ }
}
Py_DECREF(res);
return 0;