diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-07 17:20:56 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-07 17:20:56 (GMT) |
commit | 9587286f98676f7723b0f8e2da17422f8ca84bf9 (patch) | |
tree | c9b86d7b11e32ff142bfe08b29ef69d7fb4246ff /Python/importdl.c | |
parent | 53dc735168c876b5ed2e4553965014b07c03904e (diff) | |
download | cpython-9587286f98676f7723b0f8e2da17422f8ca84bf9.zip cpython-9587286f98676f7723b0f8e2da17422f8ca84bf9.tar.gz cpython-9587286f98676f7723b0f8e2da17422f8ca84bf9.tar.bz2 |
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()
Diffstat (limited to 'Python/importdl.c')
-rw-r--r-- | Python/importdl.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Python/importdl.c b/Python/importdl.c index 74ca8a7..f0e1f55 100644 --- a/Python/importdl.c +++ b/Python/importdl.c @@ -26,17 +26,23 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) dl_funcptr p0; PyObject* (*p)(void); struct PyModuleDef *def; - PyObject *result; + PyObject *nameobj, *result; path = PyUnicode_DecodeFSDefault(pathname); if (path == NULL) return NULL; - if ((m = _PyImport_FindExtensionUnicode(name, path)) != NULL) { + nameobj = PyUnicode_FromString(name); + if (nameobj == NULL) + return NULL; + m = _PyImport_FindExtensionObject(nameobj, path); + if (m != NULL) { + Py_DECREF(nameobj); Py_INCREF(m); result = m; goto finally; } + Py_DECREF(nameobj); lastdot = strrchr(name, '.'); if (lastdot == NULL) { packagecontext = NULL; @@ -82,12 +88,18 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp) else Py_INCREF(path); - if (_PyImport_FixupExtensionUnicode(m, name, path) < 0) + nameobj = PyUnicode_FromString(name); + if (nameobj == NULL) + return NULL; + if (_PyImport_FixupExtensionObject(m, nameobj, path) < 0) { + Py_DECREF(nameobj); goto error; + } if (Py_VerboseFlag) - PySys_WriteStderr( - "import %s # dynamically loaded from %s\n", - name, pathname); + PySys_FormatStderr( + "import %U # dynamically loaded from %s\n", + nameobj, pathname); + Py_DECREF(nameobj); result = m; goto finally; |