Skip to content

Commit ccab27c

Browse files
authored
Synchronize developer tools with Python 3.15 (#9298)
Regenerate bdb, pdb, codeop, modulefinder and the canonical modulefinder test using scripts/update_lib at CPython 3.15.0 d220409a13b77de7a6c30abe16ea90db01528edc. AI-assisted source selection, synchronization, dependency review and bounded validation using OpenAI Codex. Assisted-by: Codex:unknown
1 parent 1ba1107 commit ccab27c

5 files changed

Lines changed: 285 additions & 53 deletions

File tree

‎Lib/bdb.py‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,9 @@ def trace_dispatch(self, frame, event, arg):
269269
is entered.
270270
return: A function or other code block is about to return.
271271
exception: An exception has occurred.
272-
c_call: A C function is about to be called.
273-
c_return: A C function has returned.
274-
c_exception: A C function has raised an exception.
275272
276-
For the Python events, specialized functions (see the dispatch_*()
277-
methods) are called. For the C events, no action is taken.
273+
For all the events, specialized functions (see the dispatch_*()
274+
methods) are called.
278275
279276
The arg parameter depends on the previous event.
280277
"""
@@ -290,12 +287,6 @@ def trace_dispatch(self, frame, event, arg):
290287
return self.dispatch_return(frame, arg)
291288
if event == 'exception':
292289
return self.dispatch_exception(frame, arg)
293-
if event == 'c_call':
294-
return self.trace_dispatch
295-
if event == 'c_exception':
296-
return self.trace_dispatch
297-
if event == 'c_return':
298-
return self.trace_dispatch
299290
if event == 'opcode':
300291
return self.dispatch_opcode(frame, arg)
301292
print('bdb.Bdb.dispatch: unknown debugging event:', repr(event))

‎Lib/codeop.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def _maybe_compile(compiler, source, filename, symbol, flags):
6666
try:
6767
compiler(source + "\n", filename, symbol, flags=flags)
6868
return None
69-
except _IncompleteInputError as e:
69+
except _IncompleteInputError:
7070
return None
71-
except SyntaxError as e:
71+
except SyntaxError:
7272
pass
7373
# fallthrough
7474

‎Lib/modulefinder.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ def _find_module(name, path=None):
6666

6767
file_path = spec.origin
6868

69-
if spec.loader.is_package(name):
69+
# On namespace packages, spec.loader might be None, but
70+
# spec.submodule_search_locations should always be set — check it instead.
71+
if isinstance(spec.submodule_search_locations, importlib.machinery.NamespacePath):
72+
return None, spec.submodule_search_locations, ("", "", _PKG_DIRECTORY)
73+
74+
if spec.loader.is_package(name): # non-namespace package
7075
return None, os.path.dirname(file_path), ("", "", _PKG_DIRECTORY)
7176

7277
if isinstance(spec.loader, importlib.machinery.SourceFileLoader):
@@ -334,7 +339,7 @@ def load_module(self, fqname, fp, pathname, file_info):
334339
self.msgout(2, "load_module ->", m)
335340
return m
336341
if type == _PY_SOURCE:
337-
co = compile(fp.read(), pathname, 'exec')
342+
co = compile(fp.read(), pathname, 'exec', module=fqname)
338343
elif type == _PY_COMPILED:
339344
try:
340345
data = fp.read()
@@ -400,7 +405,6 @@ def scan_opcodes(self, co):
400405
yield "relative_import", (level, fromlist, name)
401406

402407
def scan_code(self, co, m):
403-
code = co.co_code
404408
scanner = self.scan_opcodes
405409
for what, args in scanner(co):
406410
if what == "store":
@@ -454,6 +458,11 @@ def load_package(self, fqname, pathname):
454458
if newname:
455459
fqname = newname
456460
m = self.add_module(fqname)
461+
462+
if isinstance(pathname, importlib.machinery.NamespacePath):
463+
m.__path__ = pathname
464+
return m
465+
457466
m.__file__ = pathname
458467
m.__path__ = [pathname]
459468

0 commit comments

Comments
 (0)