gh-117174: Fix reference leak and gdb tests (#131095)

This commit is contained in:
Pablo Galindo Salgado 2025-03-11 23:17:58 +00:00 committed by GitHub
parent c00ac57824
commit ebc24d54bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 88 additions and 83 deletions

View file

@ -51,9 +51,11 @@ def _getline_from_code(filename, lineno):
return lines[lineno - 1]
return ''
def _make_key(code):
return (code.co_filename, code.co_qualname, code.co_firstlineno)
def _getlines_from_code(code):
code_id = id(code)
code_id = _make_key(code)
if code_id in _interactive_cache:
entry = _interactive_cache[code_id]
if len(entry) != 1:
@ -215,7 +217,6 @@ def lazycache(filename, module_globals):
return True
return False
def _register_code(code, string, name):
entry = (len(string),
None,
@ -227,4 +228,4 @@ def _register_code(code, string, name):
for const in code.co_consts:
if isinstance(const, type(code)):
stack.append(const)
_interactive_cache[id(code)] = entry
_interactive_cache[_make_key(code)] = entry