Issue #1692335: Move initial args assignment to BaseException.new · python/cpython@a71a87e (original) (raw)
`@@ -10,6 +10,15 @@
`
10
10
`from test.support import (TESTFN, unlink, run_unittest, captured_output,
`
11
11
`gc_collect, cpython_only, no_tracing)
`
12
12
``
``
13
`+
class NaiveException(Exception):
`
``
14
`+
def init(self, x):
`
``
15
`+
self.x = x
`
``
16
+
``
17
`+
class SlottedNaiveException(Exception):
`
``
18
`+
slots = ('x',)
`
``
19
`+
def init(self, x):
`
``
20
`+
self.x = x
`
``
21
+
13
22
`# XXX This is not really enough, each operation should be tested!
`
14
23
``
15
24
`class ExceptionTests(unittest.TestCase):
`
`@@ -296,6 +305,10 @@ def testAttributes(self):
`
296
305
` {'args' : ('\u3042', 0, 1, 'ouch'),
`
297
306
`'object' : '\u3042', 'reason' : 'ouch',
`
298
307
`'start' : 0, 'end' : 1}),
`
``
308
`+
(NaiveException, ('foo',),
`
``
309
`+
{'args': ('foo',), 'x': 'foo'}),
`
``
310
`+
(SlottedNaiveException, ('foo',),
`
``
311
`+
{'args': ('foo',), 'x': 'foo'}),
`
299
312
` ]
`
300
313
`try:
`
301
314
`# More tests are in test_WindowsError
`
`@@ -316,7 +329,8 @@ def testAttributes(self):
`
316
329
`raise
`
317
330
`else:
`
318
331
`# Verify module name
`
319
``
`-
self.assertEqual(type(e).module, 'builtins')
`
``
332
`+
if not type(e).name.endswith('NaiveException'):
`
``
333
`+
self.assertEqual(type(e).module, 'builtins')
`
320
334
`# Verify no ref leaks in Exc_str()
`
321
335
`s = str(e)
`
322
336
`for checkArgName in expected:
`