Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
fefd70c4
Kaydet (Commit)
fefd70c4
authored
Mar 14, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #3080: _PyImport_LoadDynamicModule() uses Unicode for name and path
Document also that dynamic module names are ASCII only
üst
4d6c1c47
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
66 deletions
+60
-66
import.c
Python/import.c
+30
-24
importdl.c
Python/importdl.c
+29
-41
importdl.h
Python/importdl.h
+1
-1
No files found.
Python/import.c
Dosyayı görüntüle @
fefd70c4
...
...
@@ -2173,9 +2173,21 @@ load_module(char *name, FILE *fp, char *pathname, int type, PyObject *loader)
break
;
#ifdef HAVE_DYNAMIC_LOADING
case
C_EXTENSION
:
m
=
_PyImport_LoadDynamicModule
(
name
,
pathname
,
fp
);
case
C_EXTENSION
:
{
PyObject
*
nameobj
,
*
pathobj
;
nameobj
=
PyUnicode_FromString
(
name
);
if
(
nameobj
==
NULL
)
return
NULL
;
pathobj
=
PyUnicode_DecodeFSDefault
(
pathname
);
if
(
pathobj
==
NULL
)
{
Py_DECREF
(
nameobj
);
return
NULL
;
}
m
=
_PyImport_LoadDynamicModule
(
nameobj
,
pathobj
,
fp
);
Py_DECREF
(
nameobj
);
Py_DECREF
(
pathobj
);
break
;
}
#endif
case
PKG_DIRECTORY
:
...
...
@@ -2185,11 +2197,10 @@ load_module(char *name, FILE *fp, char *pathname, int type, PyObject *loader)
case
C_BUILTIN
:
case
PY_FROZEN
:
{
PyObject
*
nameobj
=
PyUnicode_FromString
(
name
);
if
(
nameobj
!=
NULL
)
{
m
=
load_builtin
(
nameobj
,
type
);
Py_DECREF
(
nameobj
);
}
else
m
=
NULL
;
if
(
nameobj
==
NULL
)
return
NULL
;
m
=
load_builtin
(
nameobj
,
type
);
Py_DECREF
(
nameobj
);
break
;
}
...
...
@@ -3443,28 +3454,23 @@ imp_load_compiled(PyObject *self, PyObject *args)
static
PyObject
*
imp_load_dynamic
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
name
;
PyObject
*
pathbytes
;
char
*
pathname
;
PyObject
*
fob
=
NULL
;
PyObject
*
m
;
FILE
*
fp
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"sO&|O:load_dynamic"
,
&
name
,
PyUnicode_FSConverter
,
&
pathbytes
,
&
fob
))
PyObject
*
name
,
*
pathname
,
*
fob
=
NULL
,
*
mod
;
FILE
*
fp
;
if
(
!
PyArg_ParseTuple
(
args
,
"UO&|O:load_dynamic"
,
&
name
,
PyUnicode_FSDecoder
,
&
pathname
,
&
fob
))
return
NULL
;
pathname
=
PyBytes_AS_STRING
(
pathbytes
);
if
(
fob
)
{
fp
=
get_file
(
pathname
,
fob
,
"r"
);
if
(
fp
==
NULL
)
{
Py_DECREF
(
pathbytes
);
if
(
fob
!=
NULL
)
{
fp
=
get_file
(
NULL
,
fob
,
"r"
);
if
(
fp
==
NULL
)
return
NULL
;
}
}
m
=
_PyImport_LoadDynamicModule
(
name
,
pathname
,
fp
);
Py_DECREF
(
pathbytes
);
else
fp
=
NULL
;
mod
=
_PyImport_LoadDynamicModule
(
name
,
pathname
,
fp
);
if
(
fp
)
fclose
(
fp
);
return
m
;
return
m
od
;
}
#endif
/* HAVE_DYNAMIC_LOADING */
...
...
Python/importdl.c
Dosyayı görüntüle @
fefd70c4
...
...
@@ -15,67 +15,68 @@
extern
dl_funcptr
_PyImport_GetDynLoadFunc
(
const
char
*
shortname
,
const
char
*
pathname
,
FILE
*
fp
);
/* name should be ASCII only because the C language doesn't accept non-ASCII
identifiers, and dynamic modules are written in C. */
PyObject
*
_PyImport_LoadDynamicModule
(
char
*
name
,
char
*
pathname
,
FILE
*
fp
)
_PyImport_LoadDynamicModule
(
PyObject
*
name
,
PyObject
*
path
,
FILE
*
fp
)
{
PyObject
*
m
;
PyObject
*
path
;
char
*
lastdot
,
*
shortname
,
*
packagecontext
,
*
oldcontext
;
PyObject
*
path
bytes
;
char
*
namestr
,
*
lastdot
,
*
shortname
,
*
packagecontext
,
*
oldcontext
;
dl_funcptr
p0
;
PyObject
*
(
*
p
)(
void
);
struct
PyModuleDef
*
def
;
PyObject
*
nameobj
,
*
result
;
path
=
PyUnicode_DecodeFSDefault
(
path
name
);
if
(
path
==
NULL
)
namestr
=
_PyUnicode_AsString
(
name
);
if
(
namestr
==
NULL
)
return
NULL
;
nameobj
=
PyUnicode_FromString
(
name
);
if
(
nameobj
==
NULL
)
return
NULL
;
m
=
_PyImport_FindExtensionObject
(
nameobj
,
path
);
m
=
_PyImport_FindExtensionObject
(
name
,
path
);
if
(
m
!=
NULL
)
{
Py_DECREF
(
nameobj
);
Py_INCREF
(
m
);
result
=
m
;
goto
finally
;
return
m
;
}
Py_DECREF
(
nameobj
);
lastdot
=
strrchr
(
name
,
'.'
);
lastdot
=
strrchr
(
name
str
,
'.'
);
if
(
lastdot
==
NULL
)
{
packagecontext
=
NULL
;
shortname
=
name
;
shortname
=
name
str
;
}
else
{
packagecontext
=
name
;
packagecontext
=
name
str
;
shortname
=
lastdot
+
1
;
}
p0
=
_PyImport_GetDynLoadFunc
(
shortname
,
pathname
,
fp
);
pathbytes
=
PyUnicode_EncodeFSDefault
(
path
);
if
(
pathbytes
==
NULL
)
return
NULL
;
p0
=
_PyImport_GetDynLoadFunc
(
shortname
,
PyBytes_AS_STRING
(
pathbytes
),
fp
);
Py_DECREF
(
pathbytes
);
p
=
(
PyObject
*
(
*
)(
void
))
p0
;
if
(
PyErr_Occurred
())
goto
error
;
return
NULL
;
if
(
p
==
NULL
)
{
PyErr_Format
(
PyExc_ImportError
,
"dynamic module does not define init function (PyInit_%.200s)"
,
"dynamic module does not define init function"
" (PyInit_%s)"
,
shortname
);
goto
error
;
return
NULL
;
}
oldcontext
=
_Py_PackageContext
;
_Py_PackageContext
=
packagecontext
;
m
=
(
*
p
)();
_Py_PackageContext
=
oldcontext
;
if
(
m
==
NULL
)
goto
error
;
return
NULL
;
if
(
PyErr_Occurred
())
{
Py_DECREF
(
m
);
PyErr_Format
(
PyExc_SystemError
,
"initialization of %s raised unreported exception"
,
shortname
);
goto
error
;
return
NULL
;
}
/* Remember pointer to module init function. */
...
...
@@ -88,26 +89,13 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
else
Py_INCREF
(
path
);
nameobj
=
PyUnicode_FromString
(
name
);
if
(
nameobj
==
NULL
)
if
(
_PyImport_FixupExtensionObject
(
m
,
name
,
path
)
<
0
)
return
NULL
;
if
(
_PyImport_FixupExtensionObject
(
m
,
nameobj
,
path
)
<
0
)
{
Py_DECREF
(
nameobj
);
goto
error
;
}
if
(
Py_VerboseFlag
)
PySys_FormatStderr
(
"import %U # dynamically loaded from %s
\n
"
,
nameobj
,
pathname
);
Py_DECREF
(
nameobj
);
result
=
m
;
goto
finally
;
error:
result
=
NULL
;
finally:
Py_DECREF
(
path
);
return
result
;
"import %U # dynamically loaded from %R
\n
"
,
name
,
path
);
return
m
;
}
#endif
/* HAVE_DYNAMIC_LOADING */
Python/importdl.h
Dosyayı görüntüle @
fefd70c4
...
...
@@ -28,7 +28,7 @@ struct filedescr {
extern
struct
filedescr
*
_PyImport_Filetab
;
extern
const
struct
filedescr
_PyImport_DynLoadFiletab
[];
extern
PyObject
*
_PyImport_LoadDynamicModule
(
char
*
name
,
char
*
pathname
,
extern
PyObject
*
_PyImport_LoadDynamicModule
(
PyObject
*
name
,
PyObject
*
pathname
,
FILE
*
);
/* Max length of module suffix searched for -- accommodates "module.slb" */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment