Commit graph

9949 commits

Author SHA1 Message Date
Pablo Galindo Salgado
824ac88f8b Fix eager imports in try/except in global mode 2025-10-25 23:30:16 +01:00
Dino Viehland
1f6518dcfe Grab builtins dict from module 2025-10-25 12:35:38 -07:00
Dino Viehland
5166d39584 Allow try/except in with block 2025-10-23 10:06:18 -07:00
Pablo Galindo Salgado
2e197658cc Fix another race 2025-10-21 17:18:43 +01:00
Pablo Galindo Salgado
c3b4807dac Fix bug in specialization and make reification atomic 2025-10-21 16:55:35 +01:00
Dino Viehland
a3ddde4187 Fix specialization of load global 2025-10-20 14:13:57 -07:00
Dino Viehland
06b9110569 Update sys module to conform with the PEP, add matching C API 2025-10-09 13:37:28 -07:00
Dino Viehland
d9ad012e5d Fix leaks and LOAD_ATTR specialization 2025-10-08 16:21:15 -07:00
Dino Viehland
0c246bc79d __import__ is loaded at reification time 2025-10-08 13:33:16 -07:00
Dino Viehland
c5efb20d48 Expose LazyImportType in types module 2025-10-08 13:31:57 -07:00
Dino Viehland
c63198cba4 Move eager check for from imports into import from 2025-10-07 16:20:47 -07:00
Pablo Galindo Salgado
e5e9592863 C was a mistake 2025-10-07 16:23:45 +01:00
Pablo Galindo
214b2543ee Fix global membership in LOAD_NAME 2025-10-07 11:42:13 +01:00
Pablo Galindo Salgado
5d6026a800 Make imports in with blocks syntax errors 2025-10-02 21:35:49 +01:00
Dino Viehland
7c494053b0 Don't allow __lazy_imports__ to work in try/except 2025-10-02 13:22:55 -07:00
Dino Viehland
c8c8838b1c Move __lazy_imports__ check into the interpreter 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
f67310c9b9 Add sys.set_lazy_imports_filter 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
9078f571e4 Fix __lazy_modules__ 2025-10-02 13:22:54 -07:00
Dino Viehland
b179da2cf5 Re-enable eagerly returning imported module 2025-10-02 13:22:54 -07:00
Dino Viehland
9be59ecebd Publish lazy imported packages on parent 2025-10-02 13:22:54 -07:00
Dino Viehland
781eedb9d4 Add PyExc_ImportCycleError and raise it when a cycle is detected 2025-10-02 13:22:54 -07:00
Dino Viehland
00e7800e4c Implement disabling imports in try/except and * imports, report errors on bad usage of lazy 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
164423b42b Fix submodules crash 2025-10-02 13:22:54 -07:00
Pablo Galindo
20b14d9ca4 Syntax restrictions for lazy imports 2025-10-02 13:22:54 -07:00
Pablo Galindo
07a633f1f4 Draft: force * imports to be eager 2025-10-02 13:22:54 -07:00
Pablo Galindo
73de8d0928 Add global flag 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
44a3e46770 fix offset in addr2line 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
f3f5795e31 Fix recursive lazy imports and error path in bytecodes.c 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
f9880bfd5f More fixes 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
03a419ac2d Fix reference and global dict in spezializing LOAD_GLOBAL 2025-10-02 13:22:54 -07:00
Pablo Galindo Salgado
6a911327d0 Implement better error 2025-10-02 13:22:54 -07:00
Dino Viehland
058bc6e884 Flow import func through to lazy imports object and __lazy_import__ 2025-10-02 13:22:54 -07:00
Dino Viehland
41ab092407 Add compatiblity mode 2025-10-02 13:22:53 -07:00
Dino Viehland
de281fd894 Add lazy import filter 2025-10-02 13:22:53 -07:00
Dino Viehland
9eef03cc80 Export lazy_import in imp module 2025-10-02 13:22:53 -07:00
Dino Viehland
3b0d745e73 Add __lazy_import__, check sys.modules before import 2025-10-02 13:22:53 -07:00
Dino Viehland
1c691ea756 Lazy imports grammar / AST changes 2025-10-02 13:22:53 -07:00
Victor Stinner
536787591a
Fix typo in tracemalloc.c (#139450) 2025-10-01 08:58:18 +02:00
Petr Viktorin
01157e0cdf
gh-139116: tracemalloc: Detach thread state when acquiring tables_lock (GH-139449)
* gh-139116: tracemalloc: Detach thread state when acquiring tables_lock

This prevents a deadlock when:

- One thread is in `_PyTraceMalloc_Stop`, with `TABLES_LOCK` held, calling
  `PyRefTracer_SetTracer` which wants to stop the world
- Another is thread in `PyTraceMalloc_Track`, just attached thread state, waiting
  for `TABLES_LOCK`

Detaching the thread state while waiting for `TABLES_LOCK` allows
`PyRefTracer_SetTracer` to stop the world.


Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-30 16:43:49 +02:00
Pablo Galindo Salgado
1963e70100
gh-139275: Fix compilation of Modules/_remote_debugging_module.c when the system doesn't have process_vm_readv (#139307) 2025-09-25 00:16:44 +01:00
Rok Mandeljc
7016044de9
gh-139231: Fix estimation of available stack size for recursion limit on macOS (GH-139232)
Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
2025-09-24 11:57:00 +01:00
Donghee Na
c4f21d7c7c
gh-133171: Re-enable JUMP_BACKWARD to free-threading build (gh-137800) 2025-09-24 14:19:17 +09:00
Serhiy Storchaka
1a2e00c97a
gh-67795: Accept any real numbers as timestamp and timeout (GH-139224)
Functions that take timestamp or timeout arguments now accept any
real numbers (such as Decimal and Fraction), not only integers or floats,
although this does not improve precision.
2025-09-23 21:31:42 +03:00
Victor Stinner
e8382e55c5
gh-74857, PEP 538: Coerce POSIX locale to UTF-8 based locale (#139238) 2025-09-23 19:20:59 +02:00
Peter Bierma
d06113c7a7
gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164) 2025-09-19 10:41:09 -04:00
Lisa Roach
2fd43a1ffe
gh-138310: Adds sys.audit event for import_module (#138311)
* Updates sys.audit calls for imports to include import_module
* Adds unit tests for existing and new functionality
2025-09-19 06:21:42 -07:00
Peter Bierma
9243a4b933
gh-126016: Remove bad assertion in PyThreadState_Clear (GH-139158)
In the _interpreters module, we use PyEval_EvalCode() to run Python code in another interpreter. However, when the process receives a KeyboardInterrupt, PyEval_EvalCode() will jump straight to finalization rather than returning. This prevents us from cleaning up and marking the thread as "not running main", which triggers an assertion in PyThreadState_Clear() on debug builds. Since everything else works as intended, remove that assertion.
2025-09-19 12:17:05 +00:00
Peter Bierma
3eec897752
gh-136003: Skip non-daemon threads when exceptions occur during finalization (GH-139129)
During finalization, we need to mark all non-daemon threads as daemon to quickly shut down threads when sending CTRL^C to the process. This was a minor regression from GH-136004.
2025-09-18 16:04:01 -04:00
Ken Jin
a269e691de
gh-139109: Dynamic opcode targets (GH-139111)
Make opcode targets table dynamic
2025-09-18 14:12:07 +01:00
Victor Stinner
6504f20cce
gh-135755: Make Py_TAIL_CALL_INTERP macro private (#138981)
Rename Py_TAIL_CALL_INTERP to _Py_TAIL_CALL_INTERP.
2025-09-18 14:33:07 +02:00