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
dbc52f8a
Kaydet (Commit)
dbc52f8a
authored
Mar 16, 2012
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
check for string attribute names in old-style classes (closes #14334)
üst
6e7832b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
test_class.py
Lib/test/test_class.py
+7
-0
NEWS
Misc/NEWS
+2
-1
classobject.c
Objects/classobject.c
+27
-3
No files found.
Lib/test/test_class.py
Dosyayı görüntüle @
dbc52f8a
...
...
@@ -628,6 +628,13 @@ class ClassTests(unittest.TestCase):
a
=
A
(
hash
(
A
.
f
.
im_func
)
^
(
-
1
))
hash
(
a
.
f
)
def
testAttrSlots
(
self
):
class
C
:
pass
for
c
in
C
,
C
():
self
.
assertRaises
(
TypeError
,
type
(
c
)
.
__getattribute__
,
c
,
[])
self
.
assertRaises
(
TypeError
,
type
(
c
)
.
__setattr__
,
c
,
[],
[])
def
test_main
():
with
test_support
.
check_py3k_warnings
(
(
".+__(get|set|del)slice__ has been removed"
,
DeprecationWarning
),
...
...
Misc/NEWS
Dosyayı görüntüle @
dbc52f8a
...
...
@@ -10,7 +10,8 @@ Core and Builtins
-----------------
- Issue #14334: Prevent in a segfault in type.__getattribute__ when it was not
passed strings.
passed strings. Also fix segfaults in the __getattribute__ and __setattr__
methods of old-style classes.
- Issue #14161: fix the __repr__ of file objects to escape the file name.
...
...
Objects/classobject.c
Dosyayı görüntüle @
dbc52f8a
...
...
@@ -225,10 +225,16 @@ static PyObject *
class_getattr
(
register
PyClassObject
*
op
,
PyObject
*
name
)
{
register
PyObject
*
v
;
register
char
*
sname
=
PyString_AsString
(
name
)
;
register
char
*
sname
;
PyClassObject
*
klass
;
descrgetfunc
f
;
if
(
!
PyString_Check
(
name
))
{
PyErr_SetString
(
PyExc_TypeError
,
"attribute name must be a string"
);
return
NULL
;
}
sname
=
PyString_AsString
(
name
);
if
(
sname
[
0
]
==
'_'
&&
sname
[
1
]
==
'_'
)
{
if
(
strcmp
(
sname
,
"__dict__"
)
==
0
)
{
if
(
PyEval_GetRestricted
())
{
...
...
@@ -336,6 +342,10 @@ class_setattr(PyClassObject *op, PyObject *name, PyObject *v)
"classes are read-only in restricted mode"
);
return
-
1
;
}
if
(
!
PyString_Check
(
name
))
{
PyErr_SetString
(
PyExc_TypeError
,
"attribute name must be a string"
);
return
-
1
;
}
sname
=
PyString_AsString
(
name
);
if
(
sname
[
0
]
==
'_'
&&
sname
[
1
]
==
'_'
)
{
Py_ssize_t
n
=
PyString_Size
(
name
);
...
...
@@ -699,7 +709,14 @@ static PyObject *
instance_getattr1
(
register
PyInstanceObject
*
inst
,
PyObject
*
name
)
{
register
PyObject
*
v
;
register
char
*
sname
=
PyString_AsString
(
name
);
register
char
*
sname
;
if
(
!
PyString_Check
(
name
))
{
PyErr_SetString
(
PyExc_TypeError
,
"attribute name must be a string"
);
return
NULL
;
}
sname
=
PyString_AsString
(
name
);
if
(
sname
[
0
]
==
'_'
&&
sname
[
1
]
==
'_'
)
{
if
(
strcmp
(
sname
,
"__dict__"
)
==
0
)
{
if
(
PyEval_GetRestricted
())
{
...
...
@@ -810,7 +827,14 @@ static int
instance_setattr
(
PyInstanceObject
*
inst
,
PyObject
*
name
,
PyObject
*
v
)
{
PyObject
*
func
,
*
args
,
*
res
,
*
tmp
;
char
*
sname
=
PyString_AsString
(
name
);
char
*
sname
;
if
(
!
PyString_Check
(
name
))
{
PyErr_SetString
(
PyExc_TypeError
,
"attribute name must be a string"
);
return
-
1
;
}
sname
=
PyString_AsString
(
name
);
if
(
sname
[
0
]
==
'_'
&&
sname
[
1
]
==
'_'
)
{
Py_ssize_t
n
=
PyString_Size
(
name
);
if
(
sname
[
n
-
1
]
==
'_'
&&
sname
[
n
-
2
]
==
'_'
)
{
...
...
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