Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions Lib/test/libregrtest/refleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import warnings
from inspect import isabstract
from typing import Any
import linecache

from test import support
from test.support import os_helper
Expand Down Expand Up @@ -73,6 +74,7 @@ def runtest_refleak(test_name, test_func,
ps = copyreg.dispatch_table.copy()
pic = sys.path_importer_cache.copy()
zdc: dict[str, Any] | None
linecache_data = linecache.cache.copy(), linecache._interactive_cache.copy()
try:
import zipimport
except ImportError:
Expand Down Expand Up @@ -122,7 +124,7 @@ def get_pooled_int(value):

xml_filename = 'refleak-xml.tmp'
result = None
dash_R_cleanup(fs, ps, pic, zdc, abcs)
dash_R_cleanup(fs, ps, pic, zdc, abcs, linecache_data)

for i in rep_range:
support.gc_collect()
Expand All @@ -134,7 +136,7 @@ def get_pooled_int(value):
refleak_helper._hunting_for_refleaks = current

save_support_xml(xml_filename)
dash_R_cleanup(fs, ps, pic, zdc, abcs)
dash_R_cleanup(fs, ps, pic, zdc, abcs, linecache_data)
support.gc_collect()

# Read memory statistics immediately after the garbage collection.
Expand Down Expand Up @@ -223,7 +225,7 @@ def check_fd_deltas(deltas):
return (failed, result)


def dash_R_cleanup(fs, ps, pic, zdc, abcs):
def dash_R_cleanup(fs, ps, pic, zdc, abcs, linecache_data):
import copyreg
import collections.abc

Expand All @@ -233,6 +235,11 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
copyreg.dispatch_table.update(ps)
sys.path_importer_cache.clear()
sys.path_importer_cache.update(pic)
lcache, linteractive = linecache_data
linecache._interactive_cache.clear()
linecache._interactive_cache.update(linteractive)
linecache.cache.clear()
linecache.cache.update(lcache)
try:
import zipimport
except ImportError:
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_gdb/test_pretty_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def get_gdb_repr(self, source,
# to (using its "wrap_here" function)
m = re.search(
# Match '#0 _typing_idfunc(module=..., x=...)'
r'#0\s+_typing__idfunc\s+\(module\=.*,\s+x=\s*(.*?)?\)'
r'#0\s+_typing__idfunc\s+\((?:module\=.*,\s+x=\s*(.*?)?)?\)'
# Match ' at Python/bltinmodule.c'.
# bpo-38239: typing_idfunc() is defined in Module/_typingmldule.c,
# but accept any "Directory\file.c" to support Link Time
# Optimization (LTO).
r'\s+at\s+\S*[A-Za-z]+/[A-Za-z0-9_-]+\.c',
r'\s+at\s+\S*[A-Za-z]+/[A-Za-z0-9_-]+\.[ch]',
gdb_output, re.DOTALL)
if not m:
self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
Expand Down
Loading