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
d5d32d21
Kaydet (Commit)
d5d32d21
authored
Eki 21, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28214: Improved exception reporting for problematic __set_name__
attributes.
üst
467ab194
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
test_subclassinit.py
Lib/test/test_subclassinit.py
+19
-7
NEWS
Misc/NEWS
+3
-0
typeobject.c
Objects/typeobject.c
+6
-1
No files found.
Lib/test/test_subclassinit.py
Dosyayı görüntüle @
d5d32d21
...
@@ -133,20 +133,32 @@ class Test(unittest.TestCase):
...
@@ -133,20 +133,32 @@ class Test(unittest.TestCase):
def
test_set_name_error
(
self
):
def
test_set_name_error
(
self
):
class
Descriptor
:
class
Descriptor
:
def
__set_name__
(
self
,
owner
,
name
):
def
__set_name__
(
self
,
owner
,
name
):
raise
RuntimeError
1
/
0
with
self
.
assertRaises
(
RuntimeError
):
with
self
.
assertRaises
(
RuntimeError
)
as
cm
:
class
A
:
class
NotGoingToWork
:
d
=
Descriptor
()
attr
=
Descriptor
()
exc
=
cm
.
exception
self
.
assertRegex
(
str
(
exc
),
r'\bNotGoingToWork\b'
)
self
.
assertRegex
(
str
(
exc
),
r'\battr\b'
)
self
.
assertRegex
(
str
(
exc
),
r'\bDescriptor\b'
)
self
.
assertIsInstance
(
exc
.
__cause__
,
ZeroDivisionError
)
def
test_set_name_wrong
(
self
):
def
test_set_name_wrong
(
self
):
class
Descriptor
:
class
Descriptor
:
def
__set_name__
(
self
):
def
__set_name__
(
self
):
pass
pass
with
self
.
assertRaises
(
TypeError
):
with
self
.
assertRaises
(
RuntimeError
)
as
cm
:
class
A
:
class
NotGoingToWork
:
d
=
Descriptor
()
attr
=
Descriptor
()
exc
=
cm
.
exception
self
.
assertRegex
(
str
(
exc
),
r'\bNotGoingToWork\b'
)
self
.
assertRegex
(
str
(
exc
),
r'\battr\b'
)
self
.
assertRegex
(
str
(
exc
),
r'\bDescriptor\b'
)
self
.
assertIsInstance
(
exc
.
__cause__
,
TypeError
)
def
test_set_name_lookup
(
self
):
def
test_set_name_lookup
(
self
):
resolved
=
[]
resolved
=
[]
...
...
Misc/NEWS
Dosyayı görüntüle @
d5d32d21
...
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 3
...
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 3
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #28214: Improved exception reporting for problematic __set_name__
attributes.
- Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception
- Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception
loss in PyTraceBack_Here().
loss in PyTraceBack_Here().
...
...
Objects/typeobject.c
Dosyayı görüntüle @
d5d32d21
...
@@ -7022,8 +7022,13 @@ set_names(PyTypeObject *type)
...
@@ -7022,8 +7022,13 @@ set_names(PyTypeObject *type)
if
(
set_name
!=
NULL
)
{
if
(
set_name
!=
NULL
)
{
tmp
=
PyObject_CallFunctionObjArgs
(
set_name
,
type
,
key
,
NULL
);
tmp
=
PyObject_CallFunctionObjArgs
(
set_name
,
type
,
key
,
NULL
);
Py_DECREF
(
set_name
);
Py_DECREF
(
set_name
);
if
(
tmp
==
NULL
)
if
(
tmp
==
NULL
)
{
_PyErr_FormatFromCause
(
PyExc_RuntimeError
,
"Error calling __set_name__ on '%.100s' instance %R "
"in '%.100s'"
,
value
->
ob_type
->
tp_name
,
key
,
type
->
tp_name
);
return
-
1
;
return
-
1
;
}
else
else
Py_DECREF
(
tmp
);
Py_DECREF
(
tmp
);
}
}
...
...
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