| 2246 | |
| 2247 | @classmethod |
| 2248 | def run_in_child(cls): |
| 2249 | def error(): |
| 2250 | # Create an atexit finalizer from inside a finalizer called |
| 2251 | # at exit. This should be the next to be run. |
| 2252 | g1 = weakref.finalize(cls, print, 'g1') |
| 2253 | print('f3 error') |
| 2254 | 1/0 |
| 2255 | |
| 2256 | # cls should stay alive till atexit callbacks run |
| 2257 | f1 = weakref.finalize(cls, print, 'f1', _global_var) |
| 2258 | f2 = weakref.finalize(cls, print, 'f2', _global_var) |
| 2259 | f3 = weakref.finalize(cls, error) |
| 2260 | f4 = weakref.finalize(cls, print, 'f4', _global_var) |
| 2261 | |
| 2262 | assert f1.atexit == True |
| 2263 | f2.atexit = False |
| 2264 | assert f3.atexit == True |
| 2265 | assert f4.atexit == True |
| 2266 | |
| 2267 | def test_atexit(self): |
| 2268 | prog = ('from test.test_weakref import FinalizeTestCase;'+ |