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
afd02a43
Kaydet (Commit)
afd02a43
authored
Eyl 21, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28214: Now __set_name__ is looked up on the class instead of the
instance.
üst
b00e00c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
test_subclassinit.py
Lib/test/test_subclassinit.py
+12
-0
NEWS
Misc/NEWS
+3
-0
typeobject.c
Objects/typeobject.c
+7
-5
No files found.
Lib/test/test_subclassinit.py
Dosyayı görüntüle @
afd02a43
...
...
@@ -148,6 +148,18 @@ class Test(unittest.TestCase):
class
A
:
d
=
Descriptor
()
def
test_set_name_lookup
(
self
):
resolved
=
[]
class
NonDescriptor
:
def
__getattr__
(
self
,
name
):
resolved
.
append
(
name
)
class
A
:
d
=
NonDescriptor
()
self
.
assertNotIn
(
'__set_name__'
,
resolved
,
'__set_name__ is looked up in instance dict'
)
def
test_set_name_init_subclass
(
self
):
class
Descriptor
:
def
__set_name__
(
self
,
owner
,
name
):
...
...
Misc/NEWS
Dosyayı görüntüle @
afd02a43
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 2
Core and Builtins
-----------------
- Issue #28214: Now __set_name__ is looked up on the class instead of the
instance.
- Issue #27955: Fallback on reading /dev/urandom device when the getrandom()
syscall fails with EPERM, for example when blocked by SECCOMP.
...
...
Objects/typeobject.c
Dosyayı görüntüle @
afd02a43
...
...
@@ -6990,19 +6990,21 @@ update_all_slots(PyTypeObject* type)
static
int
set_names
(
PyTypeObject
*
type
)
{
PyObject
*
key
,
*
value
,
*
tmp
;
PyObject
*
key
,
*
value
,
*
set_name
,
*
tmp
;
Py_ssize_t
i
=
0
;
while
(
PyDict_Next
(
type
->
tp_dict
,
&
i
,
&
key
,
&
value
))
{
if
(
PyObject_HasAttr
(
value
,
_PyUnicode_FromId
(
&
PyId___set_name__
)))
{
tmp
=
PyObject_CallMethodObjArgs
(
value
,
_PyUnicode_FromId
(
&
PyId___set_name__
),
type
,
key
,
NULL
);
set_name
=
lookup_maybe
(
value
,
&
PyId___set_name__
);
if
(
set_name
!=
NULL
)
{
tmp
=
PyObject_CallFunctionObjArgs
(
set_name
,
type
,
key
,
NULL
);
Py_DECREF
(
set_name
);
if
(
tmp
==
NULL
)
return
-
1
;
else
Py_DECREF
(
tmp
);
}
else
if
(
PyErr_Occurred
())
return
-
1
;
}
return
0
;
...
...
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