Fix #3634 invalid return value from _weakref.ref(Exception).__init__

Reviewers: Amaury, Antoine, Benjamin
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index c70804e..aeafdda 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -665,6 +665,14 @@
 
         w = Target()
 
+    def test_init(self):
+        # Issue 3634
+        # <weakref to class>.__init__() doesn't check errors correctly
+        r = weakref.ref(Exception)
+        self.assertRaises(TypeError, r.__init__, 0, 0, 0, 0, 0)
+        # No exception should be raised here
+        gc.collect()
+
 
 class SubclassableWeakrefTestCase(TestBase):