Commit Graph

90 Commits

Author SHA1 Message Date
Serhiy Storchaka 2d06e84455 Issue #25923: Added the const qualifier to static constant arrays. 2015-12-25 19:53:18 +02:00
Benjamin Peterson e20056c8f7 fix importing one char extension modules (closes #24328) 2015-05-29 17:10:30 -05:00
Nick Coghlan 55871f04bf Issue #24285: fix importing extensions from packages 2015-05-26 21:48:17 +10:00
Nick Coghlan d5cacbb1d9 PEP 489: Multi-phase extension module initialization
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.
2015-05-23 22:24:10 +10:00
Victor Stinner 8e54b1c448 Issue #18408: Fix _PyImport_LoadDynamicModule(), handle PyUnicode_FromFormat() failure 2013-07-17 21:53:23 +02:00
Christian Heimes 7ce57d67c9 Issue #18426: improve exception message. Courtesy of Amaury 2013-07-11 13:02:30 +02:00
Christian Heimes 848ee099f5 Issue #18426: Fix NULL pointer dereference in C extension import when
PyModule_GetDef() returns an error.
2013-07-11 11:22:21 +02:00
Brett Cannon f0434e647a Issue #14599: Generalize a test for ImportError.path and add support
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.
2012-04-20 15:22:50 -04:00
Brett Cannon fd0741555b Issue #2377: Make importlib the implementation of __import__().
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__().
2012-04-14 14:10:13 -04:00
Victor Stinner 65b7eff7c7 _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII
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.
2011-05-07 12:46:05 +02:00
Victor Stinner 2d3222740b Issue #11619: _PyImport_LoadDynamicModule() doesn't encode the path to bytes
on Windows.
2011-04-04 23:05:53 +02:00
Victor Stinner fefd70c40d Issue #3080: _PyImport_LoadDynamicModule() uses Unicode for name and path
Document also that dynamic module names are ASCII only
2011-03-14 15:54:07 -04:00
Victor Stinner 9587286f98 Issue #3080: Import builtins using Unicode strings
- 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()
2011-03-07 18:20:56 +01:00
Victor Stinner 42040fb665 Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc()
The first argument, fqname, was not used.
2011-02-22 23:16:19 +00:00
Victor Stinner 49d3f2514b _PyImport_FixupExtension() and _PyImport_FindExtension() uses FS encoding
* 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
2010-10-17 01:24:53 +00:00
Antoine Pitrou f95a1b3c53 Recorded merge of revisions 81029 via svnmerge from
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.
........
2010-05-09 15:52:27 +00:00
Martin v. Löwis 1a21451b1d Implement PEP 3121: new module initialization and finalization API. 2008-06-11 05:26:20 +00:00
Neal Norwitz e20ad358fd Move decl so it compiles with C89. 2007-10-15 16:08:26 +00:00
Guido van Rossum 00bc0e0a2d Patch #1272, by Christian Heimes and Alexandre Vassalotti.
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.
2007-10-15 02:52:41 +00:00
Martin v. Löwis e81e9b1d3b Patch #794826: Add __file__ in dynamically loaded modules for multiple
interpreters. Fixes #698282. Will backport to 2.3.
2003-09-04 18:45:59 +00:00
Fred Drake 6049cb8918 Simplify, and avoid PyModule_GetDict() while we're at it. 2002-08-26 21:15:11 +00:00
Guido van Rossum ae9e7960d3 SF patch #471839: Bug when extensions import extensions (Shane Hathaway)
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.
2001-10-16 20:07:34 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Thomas Wouters f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Guido van Rossum 96a8fb7e99 Cleanup patches from Greg Stein:
* 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
1999-12-22 14:09:35 +00:00
Guido van Rossum 6ea9092625 Moved most of the platform-specific code to dynload_<platform>.c files.
(A few nite remain, these will probably disappear soon.)

This is part of a set of patches by Greg Stein.
1999-12-20 21:20:42 +00:00
Guido van Rossum 001b9bebca Patch by Vladimir Marangozov, inspired by a bug report from Gary
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.
1999-11-16 15:54:16 +00:00
Guido van Rossum 933c91ebcf Vladimir Marangozov fixes an AIX-specific problem, writing:
"""
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).
"""
1999-08-04 18:00:12 +00:00
Guido van Rossum 54ecc3d24f Patches by William Lewis for Nextstep descendants. 1999-01-27 17:53:11 +00:00
Guido van Rossum df69365f5f Ty Sarna writes:
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.
1999-01-07 21:50:41 +00:00
Guido van Rossum cad3d47f1e Chris Herborth writes:
Donn Cave tells me the PyImport_BeImageID() function isn't needed anymore.
1999-01-04 16:45:59 +00:00
Guido van Rossum 65d5b5763c Thanks to Chris Herborth, the thread primitives now have proper Py*
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).
1998-12-21 19:32:43 +00:00
Guido van Rossum 2f3667a7b9 Replace fprintf(stderr, ...) with PySys_WriteStderr(...). 1998-10-12 18:23:55 +00:00
Guido van Rossum 0f8b30f8ce On Win32, use
LoadLibraryEx(pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
to search dependent DLLs in the directory of the pathname.
1998-10-08 01:44:41 +00:00
Guido van Rossum e364b7d46a Renamed thread.h to pythread.h.
(Also removed whitespace after # in some BEOS related cpp directives.)
1998-10-01 20:43:23 +00:00
Guido van Rossum 65f15d435e In FreeBSD when using ELF, an underscore is needed in front of the
function name.  (Vladimir Kushnir by way of Thomas Gellekum.)
1998-09-30 14:34:52 +00:00
Guido van Rossum a0f0a33d05 Mac-specific mod to enable aliases on import paths.
(Jack Jansen and/or Just van Rossum)
1998-09-14 13:40:53 +00:00
Guido van Rossum ab076fdb6f Ted Horst writes in psa-members@python.org:
This is a patch that Bill Bummgarner did for 1.4 that hasn't made its
way into the distribution yet.  This is important if you want to use
the ObjC module.
1998-08-24 14:15:44 +00:00
Guido van Rossum 1a8791e0b8 Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:46:29 +00:00
Guido van Rossum bb71ab68f9 Reindented some OS/2 and hpux code that looked ugly or at least
inconsistent.
1998-07-08 13:47:12 +00:00
Guido van Rossum a5e1b008a9 Windows-specific hack to make sure that when LoadLibrary() is called,
the filename contains at least a rudimentary pathname.
(The bad part is that we need to call getcwd() because only a prefix
of ".\\" is not enough -- we prefix the drive letter.)
1998-06-27 21:53:17 +00:00
Guido van Rossum 6b077878a5 Remove use of RTLD_GLOBAL. 1998-05-18 13:42:45 +00:00
Guido van Rossum 859b16c847 In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll. 1998-05-15 20:22:08 +00:00
Guido van Rossum 1f74016735 Support for OpenBSD :-( 1998-04-13 15:27:21 +00:00
Guido van Rossum cecadc469b Move #include <sys/param.h> to before osdefs.h (Donn Cave). 1998-04-10 23:45:14 +00:00
Guido van Rossum 42e8e5d164 Protect PyErr_Format format string argument from overflow. 1998-01-19 22:23:08 +00:00
Guido van Rossum 15af20a337 Better #ifdefs for NetBSD, taking into account that at least on netBSD
1.3, dlopen() etc. are fully implemented, including dlerror().
From Jaromir Dolecek and Ty Sarna.
1998-01-19 22:03:52 +00:00
Guido van Rossum 08052c7bb6 Add the flag RTLD_GLOBAL to the dlopen() options.
This exports symbols defined by the loaded extension to other
extensions (loaded later).

(I'm not quite sure about this but suppose it can't hurt...)
1997-12-02 20:43:18 +00:00