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
1184e266
Kaydet (Commit)
1184e266
authored
Nis 24, 2014
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
do not override errors from descriptors on modules
üst
7b9ff0e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
test_module.py
Lib/test/test_module.py
+8
-0
moduleobject.c
Objects/moduleobject.c
+9
-10
No files found.
Lib/test/test_module.py
Dosyayı görüntüle @
1184e266
...
@@ -227,6 +227,14 @@ a = A(destroyed)"""
...
@@ -227,6 +227,14 @@ a = A(destroyed)"""
b
"len = len"
,
b
"len = len"
,
b
"shutil.rmtree = rmtree"
})
b
"shutil.rmtree = rmtree"
})
def
test_descriptor_errors_propogate
(
self
):
class
Descr
:
def
__get__
(
self
,
o
,
t
):
raise
RuntimeError
class
M
(
ModuleType
):
melon
=
Descr
()
self
.
assertRaises
(
RuntimeError
,
getattr
,
M
(
"mymod"
),
"melon"
)
# frozen and namespace module reprs are tested in importlib.
# frozen and namespace module reprs are tested in importlib.
...
...
Objects/moduleobject.c
Dosyayı görüntüle @
1184e266
...
@@ -412,24 +412,23 @@ module_repr(PyModuleObject *m)
...
@@ -412,24 +412,23 @@ module_repr(PyModuleObject *m)
}
}
static
PyObject
*
static
PyObject
*
module_getattr
(
Py
Object
*
m
,
PyObject
*
name
)
module_getattr
o
(
PyModule
Object
*
m
,
PyObject
*
name
)
{
{
PyModuleObject
*
module
;
PyObject
*
attr
,
*
mod_name
;
PyObject
*
attr
,
*
mod_name
;
attr
=
PyObject_GenericGetAttr
(
m
,
name
);
attr
=
PyObject_GenericGetAttr
(
(
PyObject
*
)
m
,
name
);
if
(
attr
!=
NULL
)
if
(
attr
||
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
)
)
return
attr
;
return
attr
;
PyErr_Clear
();
PyErr_Clear
();
module
=
(
PyModuleObject
*
)
m
;
if
(
m
->
md_dict
)
{
if
(
module
->
md_dict
!=
NULL
)
{
mod_name
=
PyDict_GetItemString
(
m
->
md_dict
,
"__name__"
);
mod_name
=
PyDict_GetItemString
(
module
->
md_dict
,
"__name__"
);
if
(
mod_name
)
{
if
(
mod_name
!=
NULL
)
{
PyErr_Format
(
PyExc_AttributeError
,
PyErr_Format
(
PyExc_AttributeError
,
"module '%U' has no attribute '%U'"
,
mod_name
,
name
);
"module '%U' has no attribute '%U'"
,
mod_name
,
name
);
return
NULL
;
return
NULL
;
}
}
else
if
(
PyErr_Occurred
())
else
if
(
PyErr_Occurred
())
{
PyErr_Clear
();
PyErr_Clear
();
}
}
}
PyErr_Format
(
PyExc_AttributeError
,
PyErr_Format
(
PyExc_AttributeError
,
"module has no attribute '%U'"
,
name
);
"module has no attribute '%U'"
,
name
);
...
@@ -512,7 +511,7 @@ PyTypeObject PyModule_Type = {
...
@@ -512,7 +511,7 @@ PyTypeObject PyModule_Type = {
0
,
/* tp_hash */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_call */
0
,
/* tp_str */
0
,
/* tp_str */
module_getattr
,
/* tp_getattro */
(
getattrofunc
)
module_getattro
,
/* tp_getattro */
PyObject_GenericSetAttr
,
/* tp_setattro */
PyObject_GenericSetAttr
,
/* tp_setattro */
0
,
/* tp_as_buffer */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
|
...
...
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