Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Port the unit test to Windows
  • Loading branch information
vstinner committed May 21, 2021
commit efd45ad7881c4c1b364637f970b33cc5aeeb301d
14 changes: 6 additions & 8 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,22 +1371,20 @@ def test_ast_fini(self):
# _PyAST_Fini() which clears references to AST types.
code = textwrap.dedent("""
import ast
import builtins
import sys
import os
import codecs

# Small AST tree to keep their AST types alive
tree = ast.parse("def f(x, y): return 2*x-y")
x = [tree]
x.append(x)

# Put the cycle somewhere to survive until the last GC collection.
# Fork callbacks are only cleared at the end of
# Codec search functions are only cleared at the end of
# interpreter_clear().
def callback():
pass
callback.a = x
os.register_at_fork(after_in_child=callback)
def search_func(encoding):
return None
search_func.a = x
codecs.register(search_func)
""")
assert_python_ok("-c", code)

Expand Down