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
f841aa6f
Kaydet (Commit)
f841aa6f
authored
Mar 28, 2002
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
üst
4157ffbb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
test_descr.py
Lib/test/test_descr.py
+30
-0
xxsubtype.c
Modules/xxsubtype.c
+28
-0
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
f841aa6f
...
...
@@ -1214,6 +1214,20 @@ def classmethods():
vereq
(
ff
.
__get__
(
0
,
int
)(
42
),
(
int
,
42
))
vereq
(
ff
.
__get__
(
0
)(
42
),
(
int
,
42
))
def
classmethods_in_c
():
if
verbose
:
print
"Testing C-based class methods..."
import
xxsubtype
as
spam
a
=
(
1
,
2
,
3
)
d
=
{
'abc'
:
123
}
x
,
a1
,
d1
=
spam
.
spamlist
.
classmeth
(
*
a
,
**
d
)
veris
(
x
,
None
)
vereq
((
spam
.
spamlist
,)
+
a
,
a1
)
vereq
(
d
,
d1
)
x
,
a1
,
d1
=
spam
.
spamlist
()
.
classmeth
(
*
a
,
**
d
)
veris
(
x
,
None
)
vereq
((
spam
.
spamlist
,)
+
a
,
a1
)
vereq
(
d
,
d1
)
def
staticmethods
():
if
verbose
:
print
"Testing static methods..."
class
C
(
object
):
...
...
@@ -1231,6 +1245,20 @@ def staticmethods():
vereq
(
d
.
foo
(
1
),
(
d
,
1
))
vereq
(
D
.
foo
(
d
,
1
),
(
d
,
1
))
def
staticmethods_in_c
():
if
verbose
:
print
"Testing C-based static methods..."
import
xxsubtype
as
spam
a
=
(
1
,
2
,
3
)
d
=
{
"abc"
:
123
}
x
,
a1
,
d1
=
spam
.
spamlist
.
staticmeth
(
*
a
,
**
d
)
veris
(
x
,
None
)
vereq
(
a
,
a1
)
vereq
(
d
,
d1
)
x
,
a1
,
d2
=
spam
.
spamlist
()
.
staticmeth
(
*
a
,
**
d
)
veris
(
x
,
None
)
vereq
(
a
,
a1
)
vereq
(
d
,
d1
)
def
classic
():
if
verbose
:
print
"Testing classic classes..."
class
C
:
...
...
@@ -2884,7 +2912,9 @@ def test_main():
dynamics
()
errors
()
classmethods
()
classmethods_in_c
()
staticmethods
()
staticmethods_in_c
()
classic
()
compattr
()
newslot
()
...
...
Modules/xxsubtype.c
Dosyayı görüntüle @
f841aa6f
...
...
@@ -43,11 +43,39 @@ spamlist_setstate(spamlistobject *self, PyObject *args)
return
Py_None
;
}
static
PyObject
*
spamlist_specialmeth
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kw
)
{
PyObject
*
result
=
PyTuple_New
(
3
);
if
(
result
!=
NULL
)
{
if
(
self
==
NULL
)
self
=
Py_None
;
if
(
kw
==
NULL
)
kw
=
Py_None
;
Py_INCREF
(
self
);
PyTuple_SET_ITEM
(
result
,
0
,
self
);
Py_INCREF
(
args
);
PyTuple_SET_ITEM
(
result
,
1
,
args
);
Py_INCREF
(
kw
);
PyTuple_SET_ITEM
(
result
,
2
,
kw
);
}
return
result
;
}
static
PyMethodDef
spamlist_methods
[]
=
{
{
"getstate"
,
(
PyCFunction
)
spamlist_getstate
,
METH_VARARGS
,
"getstate() -> state"
},
{
"setstate"
,
(
PyCFunction
)
spamlist_setstate
,
METH_VARARGS
,
"setstate(state)"
},
/* These entries differ only in the flags; they are used by the tests
in test.test_descr. */
{
"classmeth"
,
(
PyCFunction
)
spamlist_specialmeth
,
METH_VARARGS
|
METH_KEYWORDS
|
METH_CLASS
,
"classmeth(*args, **kw)"
},
{
"staticmeth"
,
(
PyCFunction
)
spamlist_specialmeth
,
METH_VARARGS
|
METH_KEYWORDS
|
METH_STATIC
,
"staticmeth(*args, **kw)"
},
{
NULL
,
NULL
},
};
...
...
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