Commit graph

941 commits

Author SHA1 Message Date
Bénédikt Tran
f96a99c222 fix error path in _imp__set_lazy_attributes_impl 2025-12-07 18:51:17 -05:00
Bénédikt Tran
301481631f fix error path in _PyImport_LazyImportModuleLevelObject 2025-12-07 18:51:17 -05:00
Bénédikt Tran
74f35c42cb fix UAFs in register_lazy_on_parent 2025-12-07 18:51:17 -05:00
Bénédikt Tran
2a514d92a9 fix error path in _PyImport_LoadLazyImportTstate 2025-12-07 18:51:17 -05:00
Bénédikt Tran
093f08b8ab document return value for PyImport_GetLazyImportsFilter 2025-12-07 18:47:26 -05:00
Pablo Galindo Salgado
470b9e4362 TSAN fixes 2025-12-06 19:16:52 +00:00
Pablo Galindo Salgado
b0adc30759 Free threading fixes 2025-12-06 19:11:21 +00:00
Pablo Galindo Salgado
80133a59ff Fix error paths and edge cases 2025-12-06 18:56:06 +00:00
Pablo Galindo Salgado
4c3477ba9a moar fixes much refleaks wow 2025-12-06 18:28:28 +00:00
Pablo Galindo Salgado
4cc6905fa6 PeRfoRManCe 2025-12-06 18:23:09 +00:00
Pablo Galindo Salgado
f70d4df39c Fix smelly 2025-12-06 18:13:41 +00:00
Pablo Galindo
ea120fc6e9 Regen stuff 2025-12-06 15:44:07 +00:00
Pablo Galindo
db151a5192 Merge remote-tracking branch 'upstream/main' into lazy 2025-12-06 15:40:02 +00:00
Pablo Galindo
e6cb131a53 Implement more of PEP 810 2025-12-06 15:21:17 +00:00
Petr Viktorin
bf66bce4ee
gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (GH-141785) 2025-11-24 13:26:35 +01:00
Sam Gross
2d50dd242e
gh-137422: Fix race condition in PyImport_AddModuleRef (gh-141822) 2025-11-21 13:30:33 -05:00
Itamar Oren
1e4e59bb37
gh-116146: Add C-API to create module from spec and initfunc (GH-139196)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-11-14 10:43:25 +01:00
Petr Viktorin
a4dd66275b
gh-140550: Use a bool for the Py_mod_gil value (GH-141519)
This needs a single bit, but was stored as a void* in the module
struct. This didn't matter due to packing, but now that there's
another bool in the struct, we can save a bit of memory by
making md_gil a bool.

Variables that changed type are renamed, to detect conflicts.
2025-11-14 10:38:49 +01:00
Victor Stinner
8435a2278f
gh-141376: Fix exported symbols (GH-141377)
* gh-141376: Fix exported symbols

* _io module: add "_Py_" prefix to "spec" variables. For example,
  rename bufferedrandom_spec to _Py_bufferedrandom_spec.
* typevarobject.c: add "static" to "spec" and "slots" variables.
* import.c: add "static" to "pkgcontext" variable.

* No longer export textiowrapper_slots
2025-11-11 09:21:24 +01:00
Petr Viktorin
589a03a8ce
gh-140550: Initial implementation of PEP 793 – PyModExport (GH-140556)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-11-05 12:31:42 +01:00
Dino Viehland
8d57aca95a Merge remote-tracking branch 'origin/main' into HEAD 2025-11-03 10:10:28 -08:00
Peter Bierma
2cefa70eb9
gh-140544: Always assume that thread locals are available (GH-140690)
Python has required thread local support since 3.12 (see GH-103324). By assuming that thread locals are always supported, we can improve the performance of third-party extensions by allowing them to access the attached thread and interpreter states directly.
2025-10-28 09:07:19 -04:00
Itamar Oren
e8b5cb8f33
gh-140641: Break out of inittab search on match (GH-140642) 2025-10-27 15:18:58 +02: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
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
Dino Viehland
c8c8838b1c Move __lazy_imports__ check into the interpreter 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 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
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
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
Adam Turner
918e3ba6c0
GH-137623: Use an AC decorator for docstring line length enforcement (#137690) 2025-08-18 18:29:00 +01:00
Eric Snow
a450a0ddec
gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135491)
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true.  This allows those functions to be run with Interpreter.call().

The affected builtins:

* exec()
* eval()
* globals()
* locals()
* vars()
* dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.
2025-06-16 17:34:19 -06:00
Eric Snow
52deabefd0
gh-132775: Expand the Capability of Interpreter.call() (gh-133484)
It now supports most callables, full args, and return values.
2025-05-30 09:15:00 -06:00