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
e20056c8
Kaydet (Commit)
e20056c8
authored
May 29, 2015
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix importing one char extension modules (closes #24328)
üst
a663121e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
10 deletions
+27
-10
test_loader.py
Lib/test/test_importlib/extension/test_loader.py
+8
-0
NEWS
Misc/NEWS
+2
-0
_testmultiphase.c
Modules/_testmultiphase.c
+8
-0
importdl.c
Python/importdl.c
+9
-10
No files found.
Lib/test/test_importlib/extension/test_loader.py
Dosyayı görüntüle @
e20056c8
...
@@ -177,6 +177,14 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
...
@@ -177,6 +177,14 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
self
.
assertEqual
(
module
.
__name__
,
'pkg.'
+
self
.
name
)
self
.
assertEqual
(
module
.
__name__
,
'pkg.'
+
self
.
name
)
self
.
assertEqual
(
module
.
str_const
,
'something different'
)
self
.
assertEqual
(
module
.
str_const
,
'something different'
)
def
test_load_short_name
(
self
):
'''Test loading module with a one-character name'''
module
=
self
.
load_module_by_name
(
'x'
)
self
.
assertIsInstance
(
module
,
types
.
ModuleType
)
self
.
assertEqual
(
module
.
__name__
,
'x'
)
self
.
assertEqual
(
module
.
str_const
,
'something different'
)
assert
'x'
not
in
sys
.
modules
def
test_load_twice
(
self
):
def
test_load_twice
(
self
):
'''Test that 2 loads result in 2 module objects'''
'''Test that 2 loads result in 2 module objects'''
module1
=
self
.
load_module_by_name
(
self
.
name
)
module1
=
self
.
load_module_by_name
(
self
.
name
)
...
...
Misc/NEWS
Dosyayı görüntüle @
e20056c8
...
@@ -10,6 +10,8 @@ Release date: 2015-07-05
...
@@ -10,6 +10,8 @@ Release date: 2015-07-05
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #24328: Fix importing one character extension modules.
- Issue #11205: In dictionary displays, evaluate the key before the value.
- Issue #11205: In dictionary displays, evaluate the key before the value.
- Issue #24285: Fixed regression that prevented importing extension modules
- Issue #24285: Fixed regression that prevented importing extension modules
...
...
Modules/_testmultiphase.c
Dosyayı görüntüle @
e20056c8
...
@@ -321,6 +321,14 @@ PyInitU_eckzbwbhc6jpgzcx415x(PyObject *spec)
...
@@ -321,6 +321,14 @@ PyInitU_eckzbwbhc6jpgzcx415x(PyObject *spec)
return
PyModuleDef_Init
(
&
def_nonascii_kana
);
return
PyModuleDef_Init
(
&
def_nonascii_kana
);
}
}
/*** Module with a single-character name ***/
PyMODINIT_FUNC
PyInit_x
(
PyObject
*
spec
)
{
return
PyModuleDef_Init
(
&
main_def
);
}
/**** Testing NULL slots ****/
/**** Testing NULL slots ****/
static
PyModuleDef
null_slots_def
=
TEST_MODULE_DEF
(
static
PyModuleDef
null_slots_def
=
TEST_MODULE_DEF
(
...
...
Python/importdl.c
Dosyayı görüntüle @
e20056c8
...
@@ -34,10 +34,11 @@ static const char *nonascii_prefix = "PyInitU";
...
@@ -34,10 +34,11 @@ static const char *nonascii_prefix = "PyInitU";
*/
*/
static
PyObject
*
static
PyObject
*
get_encoded_name
(
PyObject
*
name
,
const
char
**
hook_prefix
)
{
get_encoded_name
(
PyObject
*
name
,
const
char
**
hook_prefix
)
{
char
*
buf
;
PyObject
*
tmp
;
PyObject
*
tmp
;
PyObject
*
encoded
=
NULL
;
PyObject
*
encoded
=
NULL
;
Py_ssize_t
name_len
,
lastdot
,
i
;
PyObject
*
modname
=
NULL
;
Py_ssize_t
name_len
,
lastdot
;
_Py_IDENTIFIER
(
replace
);
/* Get the short name (substring after last dot) */
/* Get the short name (substring after last dot) */
name_len
=
PyUnicode_GetLength
(
name
);
name_len
=
PyUnicode_GetLength
(
name
);
...
@@ -71,16 +72,14 @@ get_encoded_name(PyObject *name, const char **hook_prefix) {
...
@@ -71,16 +72,14 @@ get_encoded_name(PyObject *name, const char **hook_prefix) {
}
}
}
}
buf
=
PyBytes_AS_STRING
(
encoded
);
/* Replace '-' by '_' */
assert
(
Py_REFCNT
(
encoded
)
==
1
);
modname
=
_PyObject_CallMethodId
(
encoded
,
&
PyId_replace
,
"cc"
,
'-'
,
'_'
);
for
(
i
=
0
;
i
<
PyBytes_GET_SIZE
(
encoded
)
+
1
;
i
++
)
{
if
(
modname
==
NULL
)
if
(
buf
[
i
]
==
'-'
)
{
goto
error
;
buf
[
i
]
=
'_'
;
}
}
Py_DECREF
(
name
);
Py_DECREF
(
name
);
return
encoded
;
Py_DECREF
(
encoded
);
return
modname
;
error:
error:
Py_DECREF
(
name
);
Py_DECREF
(
name
);
Py_XDECREF
(
encoded
);
Py_XDECREF
(
encoded
);
...
...
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