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
547298c9
Kaydet (Commit)
547298c9
authored
Eki 17, 2012
tarafından
Eric Snow
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
üst
e54c7185
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
+23
-12
test_types.py
Lib/test/test_types.py
+9
-0
NEWS
Misc/NEWS
+2
-0
namespaceobject.c
Objects/namespaceobject.c
+12
-12
No files found.
Lib/test/test_types.py
Dosyayı görüntüle @
547298c9
...
...
@@ -1135,6 +1135,15 @@ class SimpleNamespaceTests(unittest.TestCase):
with
self
.
assertRaises
(
TypeError
):
ns
[
'spam'
]
def
test_subclass
(
self
):
class
Spam
(
types
.
SimpleNamespace
):
pass
spam
=
Spam
(
ham
=
8
,
eggs
=
9
)
self
.
assertIs
(
type
(
spam
),
Spam
)
self
.
assertEqual
(
vars
(
spam
),
{
'ham'
:
8
,
'eggs'
:
9
})
def
test_main
():
run_unittest
(
TypesTests
,
MappingProxyTests
,
ClassCreationTests
,
...
...
Misc/NEWS
Dosyayı görüntüle @
547298c9
...
...
@@ -15,6 +15,8 @@ Core and Builtins
- Issue #14783: Improve int() docstring and switch docstrings for str(),
range(), and slice() to use multi-line signatures.
- Issue #16160: Subclass support now works for types.SimpleNamespace.
- Issue #15379: Fix passing of non-BMP characters as integers for the charmap
decoder (already working as unicode strings). Patch by Serhiy Storchaka.
...
...
Objects/namespaceobject.c
Dosyayı görüntüle @
547298c9
...
...
@@ -21,19 +21,19 @@ static PyMemberDef namespace_members[] = {
static
PyObject
*
namespace_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
_PyNamespaceObject
*
ns
;
ns
=
PyObject_GC_New
(
_PyNamespaceObject
,
&
_PyNamespace_Type
);
if
(
ns
==
NULL
)
return
NULL
;
ns
->
ns_dict
=
PyDict_New
();
if
(
ns
->
ns_dict
==
NULL
)
{
Py_DECREF
(
ns
);
return
NULL
;
PyObject
*
self
;
assert
(
type
!=
NULL
&&
type
->
tp_alloc
!=
NULL
);
self
=
type
->
tp_alloc
(
type
,
0
);
if
(
self
!=
NULL
)
{
_PyNamespaceObject
*
ns
=
(
_PyNamespaceObject
*
)
self
;
ns
->
ns_dict
=
PyDict_New
();
if
(
ns
->
ns_dict
==
NULL
)
{
Py_DECREF
(
ns
);
return
NULL
;
}
}
PyObject_GC_Track
(
ns
);
return
(
PyObject
*
)
ns
;
return
self
;
}
...
...
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