<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Python/import.c, branch master</title>
<subtitle>Python interpreter</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Python/import.c?h=master</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Python/import.c?h=master'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2024-01-29T10:03:14Z</updated>
<entry>
<title>[3.11] gh-114685: Fix incorrect use of PyBUF_READ in import.c (GH-114686) (GH-114701)</title>
<updated>2024-01-29T10:03:14Z</updated>
<author>
<name>Miss Islington (bot)</name>
<email>31488909+miss-islington@users.noreply.github.com</email>
</author>
<published>2024-01-29T10:03:14Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=ee3ca96359a27e893e4f642b3d490a7d355f7da7'/>
<id>urn:sha1:ee3ca96359a27e893e4f642b3d490a7d355f7da7</id>
<content type='text'>
(cherry picked from commit 1ac1b2f9536a581f1656f0ac9330a7382420cda1)

Co-authored-by: Nikita Sobolev &lt;mail@sobolevn.me&gt;</content>
</entry>
<entry>
<title>[3.11] gh-109521: Fix obscure cases handling in PyImport_GetImporter() (GH-109522) (GH-109781)</title>
<updated>2023-10-07T13:05:13Z</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2023-10-07T13:05:13Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6a33529cf0bcfe9001af58e45ea8feab4daed265'/>
<id>urn:sha1:6a33529cf0bcfe9001af58e45ea8feab4daed265</id>
<content type='text'>
PyImport_GetImporter() now sets RuntimeError if it fails to get sys.path_hooks
or sys.path_importer_cache or they are not list and dict correspondingly.

Previously it could return NULL without setting error in obscure cases,
crash or raise SystemError if these attributes have wrong type.
(cherry picked from commit 62c7015e89cbdedb5218d4fedd45f971885f67a8)</content>
</entry>
<entry>
<title>[3.11] gh-105979: Fix exception handling in unmarshal_frozen_code (`Python/import.c`) (GH-105980). (#106100)</title>
<updated>2023-06-26T09:00:51Z</updated>
<author>
<name>Kumar Aditya</name>
<email>59607654+kumaraditya303@users.noreply.github.com</email>
</author>
<published>2023-06-26T09:00:51Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=307c59a0c1989c188ed52d187c8c510c53a414d6'/>
<id>urn:sha1:307c59a0c1989c188ed52d187c8c510c53a414d6</id>
<content type='text'>
* [3.11] gh-105979: Fix exception handling in `unmarshal_frozen_code` (`Python/import.c`) (GH-105980).
(cherry picked from commit cd5280367a3a7065d13b8f7234474f7a2e9a18fd)

Co-authored-by: chgnrdv &lt;52372310+chgnrdv@users.noreply.github.com&gt;</content>
</entry>
<entry>
<title>gh-99578: Fix refleak in _imp.create_builtin() (GH-99642)</title>
<updated>2022-11-21T11:43:23Z</updated>
<author>
<name>Miss Islington (bot)</name>
<email>31488909+miss-islington@users.noreply.github.com</email>
</author>
<published>2022-11-21T11:43:23Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=9dda9020abcf0d51d59b283a89c58c8e1fb0f574'/>
<id>urn:sha1:9dda9020abcf0d51d59b283a89c58c8e1fb0f574</id>
<content type='text'>
Fix a reference bug in _imp.create_builtin() after the creation of
the first sub-interpreter for modules "builtins" and "sys".
(cherry picked from commit cb2ef8b2acbb231c207207d3375b2f8b0077a6ee)

Co-authored-by: Victor Stinner &lt;vstinner@python.org&gt;</content>
</entry>
<entry>
<title>[3.11] gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742) (GH-93792)</title>
<updated>2022-06-14T05:51:39Z</updated>
<author>
<name>Serhiy Storchaka</name>
<email>storchaka@gmail.com</email>
</author>
<published>2022-06-14T05:51:39Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=d42b3689f4a14694f5b1ff75c155141102aa2557'/>
<id>urn:sha1:d42b3689f4a14694f5b1ff75c155141102aa2557</id>
<content type='text'>
It combines PyImport_ImportModule() and PyObject_GetAttrString()
and saves 4-6 lines of code on every use.

Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
(cherry picked from commit 6fd4c8ec7740523bb81191c013118d9d6959bc9d)
</content>
</entry>
<entry>
<title>bpo-47162: Add call trampoline to mitigate bad fpcasts on Emscripten (GH-32189)</title>
<updated>2022-03-30T19:28:33Z</updated>
<author>
<name>Christian Heimes</name>
<email>christian@python.org</email>
</author>
<published>2022-03-30T19:28:33Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=581c4434de62d9d36392f10e65866c081fb18d71'/>
<id>urn:sha1:581c4434de62d9d36392f10e65866c081fb18d71</id>
<content type='text'>
</content>
</entry>
<entry>
<title>bpo-45459: C API uses type names rather than structure names (GH-31528)</title>
<updated>2022-02-24T16:51:59Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@python.org</email>
</author>
<published>2022-02-24T16:51:59Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=042f31da552c19054acd3ef7bb6cfd857bce172b'/>
<id>urn:sha1:042f31da552c19054acd3ef7bb6cfd857bce172b</id>
<content type='text'>
Thanks to the new pytypedefs.h, it becomes to use type names like
PyObject rather like structure names like "struct _object".</content>
</entry>
<entry>
<title>bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928)</title>
<updated>2022-02-08T20:39:07Z</updated>
<author>
<name>Eric Snow</name>
<email>ericsnowcurrently@gmail.com</email>
</author>
<published>2022-02-08T20:39:07Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=81c72044a181dbbfbf689d7a977d0d99090f26a8'/>
<id>urn:sha1:81c72044a181dbbfbf689d7a977d0d99090f26a8</id>
<content type='text'>
We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code.  It is still used in a number of non-builtin stdlib modules.

The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime.  A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings).

https://bugs.python.org/issue46541#msg411799 explains the rationale for this change.

The core of the change is in:

* (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros
* Include/internal/pycore_runtime_init.h - added the static initializers for the global strings
* Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState
* Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers

I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings.  That check is added to the PR CI config.

The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()).  This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *.

The following are not changed (yet):

* stop using _Py_IDENTIFIER() in the stdlib modules
* (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API
* (maybe) intern the strings during runtime init

https://bugs.python.org/issue46541</content>
</entry>
<entry>
<title>bpo-46670: Remove unused macros in the Python directory (GH-31192)</title>
<updated>2022-02-07T15:21:52Z</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@python.org</email>
</author>
<published>2022-02-07T15:21:52Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=7d8b69e1d1f125454d8cec81ff0dee72f2bef957'/>
<id>urn:sha1:7d8b69e1d1f125454d8cec81ff0dee72f2bef957</id>
<content type='text'>
</content>
</entry>
<entry>
<title>bpo-46608: exclude marshalled-frozen data if deep-freezing to save 300 KB space  (GH-31074)</title>
<updated>2022-02-04T17:57:03Z</updated>
<author>
<name>Kumar Aditya</name>
<email>59607654+kumaraditya303@users.noreply.github.com</email>
</author>
<published>2022-02-04T17:57:03Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=bf95ff91f2c1fc5a57190491f9ccdc63458b089e'/>
<id>urn:sha1:bf95ff91f2c1fc5a57190491f9ccdc63458b089e</id>
<content type='text'>
This reduces the size of the data segment by **300 KB** of the executable because if the modules are deep-frozen then the marshalled frozen data just wastes space. This was inspired by comment by @gvanrossum in https://github.com/python/cpython/pull/29118#issuecomment-958521863. Note: There is a new option `--deepfreeze-only` in `freeze_modules.py` to change this behavior, it is on be default to save disk space.
```console 
# du -s ./python before
27892   ./python
# du -s ./python after
27524   ./python
```

Automerge-Triggered-By: GH:ericsnowcurrently</content>
</entry>
</feed>
