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
6db70331
Kaydet (Commit)
6db70331
authored
Eyl 19, 2017
tarafından
Oren Milman
Kaydeden (comit)
Serhiy Storchaka
Eyl 19, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (#3620)
üst
453408a5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
__init__.py
Lib/test/test_import/__init__.py
+12
-0
2017-09-16-22-49-16.bpo-31492.RtyteL.rst
...ore and Builtins/2017-09-16-22-49-16.bpo-31492.RtyteL.rst
+3
-0
moduleobject.c
Objects/moduleobject.c
+1
-4
ceval.c
Python/ceval.c
+4
-0
No files found.
Lib/test/test_import/__init__.py
Dosyayı görüntüle @
6db70331
...
...
@@ -400,6 +400,18 @@ class ImportTests(unittest.TestCase):
self
.
assertEqual
(
str
(
cm
.
exception
),
"cannot import name 'does_not_exist' from '<unknown module name>' (unknown location)"
)
@cpython_only
def
test_issue31492
(
self
):
# There shouldn't be an assertion failure in case of failing to import
# from a module with a bad __name__ attribute, or in case of failing
# to access an attribute of such a module.
with
swap_attr
(
os
,
'__name__'
,
None
):
with
self
.
assertRaises
(
ImportError
):
from
os
import
does_not_exist
with
self
.
assertRaises
(
AttributeError
):
os
.
does_not_exist
def
test_concurrency
(
self
):
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
))
try
:
...
...
Misc/NEWS.d/next/Core and Builtins/2017-09-16-22-49-16.bpo-31492.RtyteL.rst
0 → 100644
Dosyayı görüntüle @
6db70331
Fix assertion failures in case of failing to import from a module with a bad
``__name__`` attribute, and in case of failing to access an attribute of such
a module. Patch by Oren Milman.
Objects/moduleobject.c
Dosyayı görüntüle @
6db70331
...
...
@@ -687,14 +687,11 @@ module_getattro(PyModuleObject *m, PyObject *name)
if
(
m
->
md_dict
)
{
_Py_IDENTIFIER
(
__name__
);
mod_name
=
_PyDict_GetItemId
(
m
->
md_dict
,
&
PyId___name__
);
if
(
mod_name
)
{
if
(
mod_name
&&
PyUnicode_Check
(
mod_name
)
)
{
PyErr_Format
(
PyExc_AttributeError
,
"module '%U' has no attribute '%U'"
,
mod_name
,
name
);
return
NULL
;
}
else
if
(
PyErr_Occurred
())
{
PyErr_Clear
();
}
}
PyErr_Format
(
PyExc_AttributeError
,
"module has no attribute '%U'"
,
name
);
...
...
Python/ceval.c
Dosyayı görüntüle @
6db70331
...
...
@@ -4930,6 +4930,10 @@ import_from(PyObject *v, PyObject *name)
if
(
pkgname
==
NULL
)
{
goto
error
;
}
if
(
!
PyUnicode_Check
(
pkgname
))
{
Py_CLEAR
(
pkgname
);
goto
error
;
}
fullmodname
=
PyUnicode_FromFormat
(
"%U.%U"
,
pkgname
,
name
);
if
(
fullmodname
==
NULL
)
{
Py_DECREF
(
pkgname
);
...
...
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