| 2229 | |
| 2230 | @classmethod |
| 2231 | def run_in_child(cls): |
| 2232 | def error(): |
| 2233 | # Create an atexit finalizer from inside a finalizer called |
| 2234 | # at exit. This should be the next to be run. |
| 2235 | g1 = weakref.finalize(cls, print, 'g1') |
| 2236 | print('f3 error') |
| 2237 | 1/0 |
| 2238 | |
| 2239 | # cls should stay alive till atexit callbacks run |
| 2240 | f1 = weakref.finalize(cls, print, 'f1', _global_var) |
| 2241 | f2 = weakref.finalize(cls, print, 'f2', _global_var) |
| 2242 | f3 = weakref.finalize(cls, error) |
| 2243 | f4 = weakref.finalize(cls, print, 'f4', _global_var) |
| 2244 | |
| 2245 | assert f1.atexit == True |
| 2246 | f2.atexit = False |
| 2247 | assert f3.atexit == True |
| 2248 | assert f4.atexit == True |
| 2249 | |
| 2250 | def test_atexit(self): |
| 2251 | prog = ('from test.test_weakref import FinalizeTestCase;'+ |