diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-18 19:35:23 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-18 19:35:23 (GMT) |
commit | 9cd177526afc086a300b548588880329c32f607d (patch) | |
tree | e842c29c3f11a1bcd885863fa8ea90e40f155bc8 /Python | |
parent | 81ca7c784c4dd58dde691284321e3e220550a75c (diff) | |
download | cpython-9cd177526afc086a300b548588880329c32f607d.zip cpython-9cd177526afc086a300b548588880329c32f607d.tar.gz cpython-9cd177526afc086a300b548588880329c32f607d.tar.bz2 |
Merged revisions 59005-59040 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
I've tried to fix test_cmd_line_script but I wasn't able to get all tests
right. Nick, can you please have a look?
........
r59020 | facundo.batista | 2007-11-16 19:04:14 +0100 (Fri, 16 Nov 2007) | 12 lines
Now in find, rfind, index, and rindex, you can use None as defaults,
as usual with slicing (both with str and unicode strings). This
fixes issue 1259.
For str only the stringobject.c file was modified. But for unicode,
I needed to repeat in the four functions a lot of code, so created
a new function that does part of the job for them (and placed it in
find.h, following a suggestion of Barry).
Also added tests for this behaviour.
........
r59021 | facundo.batista | 2007-11-16 19:41:24 +0100 (Fri, 16 Nov 2007) | 4 lines
Fix for stupid error (I need to remember to do a full 'make clean + make'
cycle before the tests...). Sorry.
........
r59022 | facundo.batista | 2007-11-16 20:16:15 +0100 (Fri, 16 Nov 2007) | 3 lines
Made _ParseTupleFinds only defined to unicodeobject.c
........
r59024 | raymond.hettinger | 2007-11-17 02:51:22 +0100 (Sat, 17 Nov 2007) | 1 line
Fix signature in example
........
r59033 | brett.cannon | 2007-11-17 08:07:29 +0100 (Sat, 17 Nov 2007) | 5 lines
Remove a confusing sentence about pth files and which directories are searched
for them.
Closes issue #1431. Thanks Giambattista Bloisi for the help.
........
r59039 | nick.coghlan | 2007-11-18 12:56:28 +0100 (Sun, 18 Nov 2007) | 1 line
Patch #1739468: Directories and zipfiles containing __main__.py are now executable
........
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c index b97b3eb..1ea9297 100644 --- a/Python/import.c +++ b/Python/import.c @@ -109,7 +109,6 @@ static const struct filedescr _PyImport_StandardFiletab[] = { {0, 0} }; -static PyTypeObject NullImporterType; /* Forward reference */ /* Initialize things */ @@ -167,7 +166,7 @@ _PyImportHooks_Init(void) /* adding sys.path_hooks and sys.path_importer_cache, setting up zipimport */ - if (PyType_Ready(&NullImporterType) < 0) + if (PyType_Ready(&PyNullImporter_Type) < 0) goto error; if (Py_VerboseFlag) @@ -1088,7 +1087,7 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, } if (importer == NULL) { importer = PyObject_CallFunctionObjArgs( - (PyObject *)&NullImporterType, p, NULL + (PyObject *)&PyNullImporter_Type, p, NULL ); if (importer == NULL) { if (PyErr_ExceptionMatches(PyExc_ImportError)) { @@ -1106,6 +1105,20 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, return importer; } +PyAPI_FUNC(PyObject *) +PyImport_GetImporter(PyObject *path) { + PyObject *importer=NULL, *path_importer_cache=NULL, *path_hooks=NULL; + + if ((path_importer_cache = PySys_GetObject("path_importer_cache"))) { + if ((path_hooks = PySys_GetObject("path_hooks"))) { + importer = get_path_importer(path_importer_cache, + path_hooks, path); + } + } + Py_XINCREF(importer); /* get_path_importer returns a borrowed reference */ + return importer; +} + /* Search the path (default sys.path) for a module. Return the corresponding filedescr struct, and (via return arguments) the pathname and an open file. Return NULL if the module is not found. */ @@ -2981,7 +2994,7 @@ static PyMethodDef NullImporter_methods[] = { }; -static PyTypeObject NullImporterType = { +PyTypeObject PyNullImporter_Type = { PyVarObject_HEAD_INIT(NULL, 0) "imp.NullImporter", /*tp_name*/ sizeof(NullImporter), /*tp_basicsize*/ @@ -3028,7 +3041,7 @@ initimp(void) { PyObject *m, *d; - if (PyType_Ready(&NullImporterType) < 0) + if (PyType_Ready(&PyNullImporter_Type) < 0) goto failure; m = Py_InitModule4("imp", imp_methods, doc_imp, @@ -3050,8 +3063,8 @@ initimp(void) if (setint(d, "PY_CODERESOURCE", PY_CODERESOURCE) < 0) goto failure; if (setint(d, "IMP_HOOK", IMP_HOOK) < 0) goto failure; - Py_INCREF(&NullImporterType); - PyModule_AddObject(m, "NullImporter", (PyObject *)&NullImporterType); + Py_INCREF(&PyNullImporter_Type); + PyModule_AddObject(m, "NullImporter", (PyObject *)&PyNullImporter_Type); failure: ; } |