From 47b9809d231c4359c56316130a76f13de2b907f7 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 3 May 2015 23:23:18 +0100 Subject: py: Check that arg to object.__new__ is a user-defined type. Addresses issue #1203. --- tests/basics/object_new.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/basics/object_new.py') diff --git a/tests/basics/object_new.py b/tests/basics/object_new.py index 6131ed337..befb5bfc2 100644 --- a/tests/basics/object_new.py +++ b/tests/basics/object_new.py @@ -18,3 +18,13 @@ o.__init__() #print(dir(o)) print(hasattr(o, "attr")) print(o.attr) + +# should only be able to call __new__ on user types +try: + object.__new__(1) +except TypeError: + print("TypeError") +try: + object.__new__(int) +except TypeError: + print("TypeError") -- cgit v1.2.3