summaryrefslogtreecommitdiffstats
path: root/Python/importdl.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) 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
* Fix format string in _PyImport_LoadDynamicModuleWithSpec() (GH-28863)Serhiy Storchaka2021-10-121-1/+1
|
* Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)Dong-hee Na2021-10-111-0/+3
|
* Fix a leak in _PyImport_LoadDynamicModuleWithSpec() after failing ↵Serhiy Storchaka2021-10-111-1/+1
| | | | PySys_Audit() (GH-28862)
* bpo-1635741: Fix ref leak in _PyWarnings_Init() error path (GH-23151)Victor Stinner2020-11-041-3/+2
| | | | | | Replace PyModule_AddObject() with PyModule_AddObjectRef() in the _warnings module to fix a reference leak on error. Use also PyModule_AddObjectRef() in importdl.c.
* bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)Andy Lester2020-03-041-1/+1
|
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-0/+5
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name ↵Oren Milman2017-09-191-0/+5
| | | | is not a string. (#3257)
* bpo-28411: Isolate PyInterpreterState.modules (#3575)Eric Snow2017-09-141-1/+2
| | | | | A bunch of code currently uses PyInterpreterState.modules directly instead of PyImport_GetModuleDict(). This complicates efforts to make changes relative to sys.modules. This patch switches to using PyImport_GetModuleDict() uniformly. Also, a number of related uses of sys.modules are updated for uniformity for the same reason. Note that this code was already reviewed and merged as part of #1638. I reverted that and am now splitting it up into more focused parts.
* bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#3565)Eric Snow2017-09-141-2/+1
| | | PR #1638, for bpo-28411, causes problems in some (very) edge cases. Until that gets sorted out, we're reverting the merge. PR #3506, a fix on top of #1638, is also getting reverted.
* bpo-28411: Remove "modules" field from Py_InterpreterState. (#1638)Eric Snow2017-09-041-1/+2
| | | sys.modules is the one true source.
* Issue #28748: Private variable _Py_PackageContext is now of type "const char *"Serhiy Storchaka2016-11-211-1/+1
| | | | rather of "char *".
* Issue #28715: Added error checks for PyUnicode_AsUTF8().Serhiy Storchaka2016-11-201-0/+4
|\
| * Issue #28715: Added error checks for PyUnicode_AsUTF8().Serhiy Storchaka2016-11-201-0/+4
| |
* | Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka2015-12-251-2/+2
|/
* fix importing one char extension modules (closes #24328)Benjamin Peterson2015-05-291-10/+9
|
* Issue #24285: fix importing extensions from packagesNick Coghlan2015-05-261-1/+1
|
* PEP 489: Multi-phase extension module initializationNick Coghlan2015-05-231-61/+166
| | | | | | | | | | | | | | | | | | | | | | | Known limitations of the current implementation: - documentation changes are incomplete - there's a reference leak I haven't tracked down yet The leak is most visible by running: ./python -m test -R3:3 test_importlib However, you can also see it by running: ./python -X showrefcount Importing the array or _testmultiphase modules, and then deleting them from both sys.modules and the local namespace shows significant increases in the total number of active references each cycle. By contrast, with _testcapi (which continues to use single-phase initialisation) the global refcounts stabilise after a couple of cycles.
* Issue #18408: Fix _PyImport_LoadDynamicModule(), handle ↵Victor Stinner2013-07-171-0/+2
| | | | PyUnicode_FromFormat() failure
* Issue #18426: improve exception message. Courtesy of AmauryChristian Heimes2013-07-111-1/+5
|
* Issue #18426: Fix NULL pointer dereference in C extension import whenChristian Heimes2013-07-111-0/+2
| | | | PyModule_GetDef() returns an error.
* Issue #14599: Generalize a test for ImportError.path and add supportBrett Cannon2012-04-201-4/+5
| | | | | | | in Python/dynload_shlibs.c. This should fix the remaining importlib test failure on Windows. Support in AIX and HP-UX will be in a separate checkin.
* Issue #2377: Make importlib the implementation of __import__().Brett Cannon2012-04-141-4/+0
| | | | | | | importlib._bootstrap is now frozen into Python/importlib.h and stored as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen code along with sys and imp and then uses _frozen_importlib._install() to set builtins.__import__() w/ _frozen_importlib.__import__().
* _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCIIVictor Stinner2011-05-071-15/+25
| | | | | | The name must be encodable to ASCII because dynamic module must have a function called "PyInit_NAME", they are written in C, and the C language doesn't accept non-ASCII identifiers.
* Issue #11619: _PyImport_LoadDynamicModule() doesn't encode the path to bytesVictor Stinner2011-04-041-0/+11
| | | | on Windows.
* Issue #3080: _PyImport_LoadDynamicModule() uses Unicode for name and pathVictor Stinner2011-03-141-41/+29
| | | | Document also that dynamic module names are ASCII only
* Issue #3080: Import builtins using Unicode stringsVictor Stinner2011-03-071-6/+18
| | | | | | | - is_builtin(), init_builtin(), load_builtin() and other builtin related functions use Unicode strings, instead of byte strings - Rename _PyImport_FixupExtensionUnicode() to _PyImport_FixupExtensionObject() - Rename _PyImport_FindExtensionUnicode() to _PyImport_FindExtensionObject()
* Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc()Victor Stinner2011-02-221-3/+2
| | | | The first argument, fqname, was not used.
* _PyImport_FixupExtension() and _PyImport_FindExtension() uses FS encodingVictor Stinner2010-10-171-10/+24
| | | | | | | * Rename _PyImport_FindExtension() to _PyImport_FindExtensionUnicode(): the filename becomes a Unicode object instead of byte string * Rename _PyImport_FixupExtension() to _PyImport_FixupExtensionUnicode(): the filename becomes a Unicode object instead of byte string
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-58/+58
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* Implement PEP 3121: new module initialization and finalization API.Martin v. Löwis2008-06-111-11/+19
|
* Move decl so it compiles with C89.Neal Norwitz2007-10-151-1/+1
|
* Patch #1272, by Christian Heimes and Alexandre Vassalotti.Guido van Rossum2007-10-151-1/+3
| | | | | | | | | | Changes to make __file__ a proper Unicode object, using the default filesystem encoding. This is a bit tricky because the default filesystem encoding isn't set by the time we import the first modules; at that point we fudge things a bit. This is okay since __file__ isn't really used much except for error reporting. Tested on OSX and Linux only so far.
* Patch #794826: Add __file__ in dynamically loaded modules for multipleMartin v. Löwis2003-09-041-2/+3
| | | | interpreters. Fixes #698282. Will backport to 2.3.
* Simplify, and avoid PyModule_GetDict() while we're at it.Fred Drake2002-08-261-5/+2
|
* SF patch #471839: Bug when extensions import extensions (Shane Hathaway)Guido van Rossum2001-10-161-2/+3
| | | | | | | | | | | | | | | | | When an extension imports another extension in its initXXX() function, the variable _Py_PackageContext is prematurely reset to NULL. If the outer extension then calls Py_InitModule(), the extension is installed in sys.modules without its package name. The manifestation of this bug is a "SystemError: _PyImport_FixupExtension: module <package>.<extension> not loaded". To fix this, importdl.c just needs to retain the old value of _Py_PackageContext and restore it after the initXXX() method is called. The attached patch does this. This patch applies to Python 2.1.1 and the current CVS.
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters2000-07-221-4/+1
| | | | declarations yet, those come later.
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Cleanup patches from Greg Stein:Guido van Rossum1999-12-221-65/+13
| | | | | | | | | | | | | | | | | | | * in import.c, #ifdef out references to dynamic loading based on HAVE_DYNAMIC_LOADING * clean out the platform-specific crud from importdl.c. [ maybe fold this function into import.c and drop the importdl.c file? Greg.] * change GetDynLoadFunc's "funcname" parameter to "shortname". change "name" to "fqname" for clarification. * each GetDynLoadFunc now creates its own funcname value. WARNING: as I mentioned previously, we may run into an issue with a missing "_" on some platforms. Testing will show this pretty quickly, however. * move pathname munging into dynload_shlib.c
* Moved most of the platform-specific code to dynload_<platform>.c files.Guido van Rossum1999-12-201-1029/+26
| | | | | | (A few nite remain, these will probably disappear soon.) This is part of a set of patches by Greg Stein.
* Patch by Vladimir Marangozov, inspired by a bug report from GaryGuido van Rossum1999-11-161-1/+7
| | | | | | | Duzan, for AIX, to support C++ objects with static initializers, when using the genuine IBM C++ compiler (namely xlC/xlC_r). See accompanying patches to configure.in and acconfig.h.
* Vladimir Marangozov fixes an AIX-specific problem, writing:Guido van Rossum1999-08-041-4/+7
| | | | | | | | | | | | | """ Following up Robin Dunn's troubles with freeze, here's a patch that fixes an oddity regarding the import logic of shared modules on AIX. Symbol resolution of shared modules is now handled properly for the cases when the python library is linked to a binary with an arbitrary name. This includes the standard python[version] executable, but also applications that are embedding the python core (i.e. linked with libpython[version].a, the latter being static or shared). """
* Patches by William Lewis for Nextstep descendants.Guido van Rossum1999-01-271-4/+71
|
* Ty Sarna writes:Guido van Rossum1999-01-071-1/+1
| | | | | | | | | The following patches (relative to 1.5.2b1) enable Python dynamic loading to work on NetBSD platforms that use ELF (presnetly mips and alpha systems). They automaticly determine wether the system is ELF or a.out rather than using astatic list of platforms so that when other NetBSD platforms move to ELF, python will continue to work without change.
* Chris Herborth writes:Guido van Rossum1999-01-041-38/+4
| | | | Donn Cave tells me the PyImport_BeImageID() function isn't needed anymore.
* Thanks to Chris Herborth, the thread primitives now have proper Py*Guido van Rossum1998-12-211-1/+1
| | | | | names in the source code (they already had those for the linker, through some smart macros; but the source still had the old, un-Py names).
* Replace fprintf(stderr, ...) with PySys_WriteStderr(...).Guido van Rossum1998-10-121-1/+1
|
* On Win32, useGuido van Rossum1998-10-081-1/+4
| | | | | LoadLibraryEx(pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) to search dependent DLLs in the directory of the pathname.