Mercurial > cpython-lru_cache-weakref
annotate Python/importdl.c @ 58664:993f703a61ba
Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines
Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done
partially before. Also add a comment describing how this might have to work
with different versions of the interpreter.
........
r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line
Fixed typo
........
r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line
#7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such.
........
r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line
Add note about usage of STRINGLIB_EMPTY.
........
r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line
Fix internal reference.
........
r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines
data descriptors do not override the class dictionary if __get__ is not defined
Adjust documentation and add a test to verify this behavior.
See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for
discussion.
........
r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines
Do not compile stubs for the sha2 series hashes in the openssl hashlib
module when the openssl version is too old to support them. That
leads both compiled code bloat and to unittests attempting to test
implementations that don't exist for comparison purposes on such
platforms.
........
r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line
Add two more test_strtod test values.
........
r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line
#7762: fix refcount annotation of PyUnicode_Tailmatch().
........
r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line
#7725: fix referencing issue.
........
r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line
mention from_float() in error message
........
r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line
#7802: fix invalid example (heh).
........
r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines
Fix-up ftplib documentation:
move exception descriptions to toplevel, not inside a class
remove attribution in "versionadded"
spell and grammar check docstring of FTP_TLS
........
r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line
Minor modification to unittest documentation.
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 03 Feb 2010 02:35:45 +0000 |
| parents | 94f64f11fdd0 |
| children | cab14be0ada1 |
| rev | line source |
|---|---|
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 /* Support for dynamic loading of extension modules */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
4 #include "Python.h" |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
5 |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
6 /* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
7 supported on this platform. configure will then compile and link in one |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
8 of the dynload_*.c files, as appropriate. We will call a function in |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
9 those modules to get a function pointer to the module's init function. |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
10 */ |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
11 #ifdef HAVE_DYNAMIC_LOADING |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
12 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 #include "importdl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
11600
14561e8395bb
Moved most of the platform-specific code to dynload_<platform>.c files.
Guido van Rossum <guido@python.org>
parents:
11469
diff
changeset
|
15 extern dl_funcptr _PyImport_GetDynLoadFunc(const char *name, |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
16 const char *shortname, |
|
11600
14561e8395bb
Moved most of the platform-specific code to dynload_<platform>.c files.
Guido van Rossum <guido@python.org>
parents:
11469
diff
changeset
|
17 const char *pathname, FILE *fp); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
3898
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
19 |
|
11600
14561e8395bb
Moved most of the platform-specific code to dynload_<platform>.c files.
Guido van Rossum <guido@python.org>
parents:
11469
diff
changeset
|
20 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
21 PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
22 _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 { |
|
25040
db49ee76b7d0
Simplify, and avoid PyModule_GetDict() while we're at it.
Fred Drake <fdrake@acm.org>
parents:
20462
diff
changeset
|
24 PyObject *m; |
|
43573
50599bbb0c67
Move decl so it compiles with C89.
Neal Norwitz <nnorwitz@gmail.com>
parents:
43569
diff
changeset
|
25 PyObject *path; |
|
20462
2f0c5af4d5ea
SF patch #471839: Bug when extensions import extensions (Shane Hathaway)
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
26 char *lastdot, *shortname, *packagecontext, *oldcontext; |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
27 dl_funcptr p0; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
28 PyObject* (*p)(void); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
29 struct PyModuleDef *def; |
|
11600
14561e8395bb
Moved most of the platform-specific code to dynload_<platform>.c files.
Guido van Rossum <guido@python.org>
parents:
11469
diff
changeset
|
30 |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
31 if ((m = _PyImport_FindExtension(name, pathname)) != NULL) { |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
32 Py_INCREF(m); |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
33 return m; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
34 } |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
35 lastdot = strrchr(name, '.'); |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
36 if (lastdot == NULL) { |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
37 packagecontext = NULL; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
38 shortname = name; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
39 } |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
40 else { |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
41 packagecontext = name; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
42 shortname = lastdot+1; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
43 } |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
44 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
45 p0 = _PyImport_GetDynLoadFunc(name, shortname, pathname, fp); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
46 p = (PyObject*(*)(void))p0; |
|
11600
14561e8395bb
Moved most of the platform-specific code to dynload_<platform>.c files.
Guido van Rossum <guido@python.org>
parents:
11469
diff
changeset
|
47 if (PyErr_Occurred()) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 if (p == NULL) { |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
50 PyErr_Format(PyExc_ImportError, |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
51 "dynamic module does not define init function (PyInit_%.200s)", |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
52 shortname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 } |
|
20462
2f0c5af4d5ea
SF patch #471839: Bug when extensions import extensions (Shane Hathaway)
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
55 oldcontext = _Py_PackageContext; |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
56 _Py_PackageContext = packagecontext; |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
57 m = (*p)(); |
|
20462
2f0c5af4d5ea
SF patch #471839: Bug when extensions import extensions (Shane Hathaway)
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
58 _Py_PackageContext = oldcontext; |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
59 if (m == NULL) |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
60 return NULL; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
62 if (PyErr_Occurred()) { |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
63 Py_DECREF(m); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
64 PyErr_Format(PyExc_SystemError, |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
65 "initialization of %s raised unreported exception", |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
66 shortname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 } |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
69 |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
70 /* Remember pointer to module init function. */ |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
71 def = PyModule_GetDef(m); |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
72 def->m_base.m_init = p; |
|
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
73 |
| 4042 | 74 /* Remember the filename as the __file__ attribute */ |
|
43569
19319e70fc3e
Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Guido van Rossum <guido@python.org>
parents:
30316
diff
changeset
|
75 path = PyUnicode_DecodeFSDefault(pathname); |
|
19319e70fc3e
Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Guido van Rossum <guido@python.org>
parents:
30316
diff
changeset
|
76 if (PyModule_AddObject(m, "__file__", path) < 0) |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
77 PyErr_Clear(); /* Not important enough to report */ |
|
30316
19611d101d23
Patch #794826: Add __file__ in dynamically loaded modules for multiple
Martin v. Löwis <martin@v.loewis.de>
parents:
25040
diff
changeset
|
78 |
|
47580
94f64f11fdd0
Implement PEP 3121: new module initialization and finalization API.
Martin v. Löwis <martin@v.loewis.de>
parents:
43573
diff
changeset
|
79 if (_PyImport_FixupExtension(m, name, pathname) < 0) |
|
30316
19611d101d23
Patch #794826: Add __file__ in dynamically loaded modules for multiple
Martin v. Löwis <martin@v.loewis.de>
parents:
25040
diff
changeset
|
80 return NULL; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
81 if (Py_VerboseFlag) |
|
9329
7f242f29a45f
Replace fprintf(stderr, ...) with PySys_WriteStderr(...).
Guido van Rossum <guido@python.org>
parents:
9299
diff
changeset
|
82 PySys_WriteStderr( |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 "import %s # dynamically loaded from %s\n", |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 name, pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 return m; |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
86 } |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11600
diff
changeset
|
87 |
|
11600
14561e8395bb
Moved most of the platform-specific code to dynload_<platform>.c files.
Guido van Rossum <guido@python.org>
parents:
11469
diff
changeset
|
88 #endif /* HAVE_DYNAMIC_LOADING */ |
