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
7f573f73
Kaydet (Commit)
7f573f73
authored
Nis 13, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a test for Py_ssize_t. Correct typo in getargs.c.
üst
b1ed7fac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
14 deletions
+41
-14
test_getargs2.py
Lib/test/test_getargs2.py
+18
-1
_testcapimodule.c
Modules/_testcapimodule.c
+21
-11
getargs.c
Python/getargs.c
+2
-2
No files found.
Lib/test/test_getargs2.py
Dosyayı görüntüle @
7f573f73
...
...
@@ -48,7 +48,7 @@ LARGE = 0x7FFFFFFF
VERY_LARGE
=
0xFF0000121212121212121242
L
from
_testcapi
import
UCHAR_MAX
,
USHRT_MAX
,
UINT_MAX
,
ULONG_MAX
,
INT_MAX
,
\
INT_MIN
,
LONG_MIN
,
LONG_MAX
INT_MIN
,
LONG_MIN
,
LONG_MAX
,
PY_SSIZE_T_MIN
,
PY_SSIZE_T_MAX
# fake, they are not defined in Python's header files
LLONG_MAX
=
2
**
63
-
1
...
...
@@ -182,6 +182,23 @@ class Signed_TestCase(unittest.TestCase):
self
.
failUnlessEqual
(
42
,
getargs_l
(
42L
))
self
.
assertRaises
(
OverflowError
,
getargs_l
,
VERY_LARGE
)
def
test_n
(
self
):
from
_testcapi
import
getargs_n
# n returns 'Py_ssize_t', and does range checking
# (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX)
self
.
failUnlessEqual
(
3
,
getargs_n
(
3.14
))
self
.
failUnlessEqual
(
99
,
getargs_n
(
Long
()))
self
.
failUnlessEqual
(
99
,
getargs_n
(
Int
()))
self
.
assertRaises
(
OverflowError
,
getargs_n
,
PY_SSIZE_T_MIN
-
1
)
self
.
failUnlessEqual
(
PY_SSIZE_T_MIN
,
getargs_n
(
PY_SSIZE_T_MIN
))
self
.
failUnlessEqual
(
PY_SSIZE_T_MAX
,
getargs_n
(
PY_SSIZE_T_MAX
))
self
.
assertRaises
(
OverflowError
,
getargs_n
,
PY_SSIZE_T_MAX
+
1
)
self
.
failUnlessEqual
(
42
,
getargs_n
(
42
))
self
.
failUnlessEqual
(
42
,
getargs_n
(
42L
))
self
.
assertRaises
(
OverflowError
,
getargs_n
,
VERY_LARGE
)
class
LongLong_TestCase
(
unittest
.
TestCase
):
def
test_L
(
self
):
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
7f573f73
...
...
@@ -360,6 +360,15 @@ getargs_l(PyObject *self, PyObject *args)
return
PyLong_FromLong
(
value
);
}
static
PyObject
*
getargs_n
(
PyObject
*
self
,
PyObject
*
args
)
{
Py_ssize_t
value
;
if
(
!
PyArg_ParseTuple
(
args
,
"n"
,
&
value
))
return
NULL
;
return
PyInt_FromSsize_t
(
value
);
}
#ifdef HAVE_LONG_LONG
static
PyObject
*
getargs_L
(
PyObject
*
self
,
PyObject
*
args
)
...
...
@@ -661,17 +670,18 @@ static PyMethodDef TestMethods[] = {
{
"test_k_code"
,
(
PyCFunction
)
test_k_code
,
METH_NOARGS
},
{
"test_null_strings"
,
(
PyCFunction
)
test_null_strings
,
METH_NOARGS
},
{
"getargs_b"
,
(
PyCFunction
)
getargs_b
,
METH_VARARGS
},
{
"getargs_B"
,
(
PyCFunction
)
getargs_B
,
METH_VARARGS
},
{
"getargs_H"
,
(
PyCFunction
)
getargs_H
,
METH_VARARGS
},
{
"getargs_I"
,
(
PyCFunction
)
getargs_I
,
METH_VARARGS
},
{
"getargs_k"
,
(
PyCFunction
)
getargs_k
,
METH_VARARGS
},
{
"getargs_i"
,
(
PyCFunction
)
getargs_i
,
METH_VARARGS
},
{
"getargs_l"
,
(
PyCFunction
)
getargs_l
,
METH_VARARGS
},
{
"getargs_b"
,
getargs_b
,
METH_VARARGS
},
{
"getargs_B"
,
getargs_B
,
METH_VARARGS
},
{
"getargs_H"
,
getargs_H
,
METH_VARARGS
},
{
"getargs_I"
,
getargs_I
,
METH_VARARGS
},
{
"getargs_k"
,
getargs_k
,
METH_VARARGS
},
{
"getargs_i"
,
getargs_i
,
METH_VARARGS
},
{
"getargs_l"
,
getargs_l
,
METH_VARARGS
},
{
"getargs_n"
,
getargs_n
,
METH_VARARGS
},
#ifdef HAVE_LONG_LONG
{
"getargs_L"
,
(
PyCFunction
)
getargs_L
,
METH_VARARGS
},
{
"getargs_K"
,
(
PyCFunction
)
getargs_K
,
METH_VARARGS
},
{
"test_longlong_api"
,
(
PyCFunction
)
test_longlong_api
,
METH_NOARGS
},
{
"getargs_L"
,
getargs_L
,
METH_VARARGS
},
{
"getargs_K"
,
getargs_K
,
METH_VARARGS
},
{
"test_longlong_api"
,
test_longlong_api
,
METH_NOARGS
},
{
"test_L_code"
,
(
PyCFunction
)
test_L_code
,
METH_NOARGS
},
{
"codec_incrementalencoder"
,
(
PyCFunction
)
codec_incrementalencoder
,
METH_VARARGS
},
...
...
@@ -682,7 +692,7 @@ static PyMethodDef TestMethods[] = {
{
"test_u_code"
,
(
PyCFunction
)
test_u_code
,
METH_NOARGS
},
#endif
#ifdef WITH_THREAD
{
"_test_thread_state"
,
(
PyCFunction
)
test_thread_state
,
METH_VARARGS
},
{
"_test_thread_state"
,
test_thread_state
,
METH_VARARGS
},
#endif
{
NULL
,
NULL
}
/* sentinel */
};
...
...
Python/getargs.c
Dosyayı görüntüle @
7f573f73
...
...
@@ -647,10 +647,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
Py_ssize_t
*
p
=
va_arg
(
*
p_va
,
Py_ssize_t
*
);
Py_ssize_t
ival
;
if
(
float_argument_error
(
arg
))
return
converterr
(
"integer<
i
>"
,
arg
,
msgbuf
,
bufsize
);
return
converterr
(
"integer<
n
>"
,
arg
,
msgbuf
,
bufsize
);
ival
=
PyInt_AsSsize_t
(
arg
);
if
(
ival
==
-
1
&&
PyErr_Occurred
())
return
converterr
(
"integer<
i
>"
,
arg
,
msgbuf
,
bufsize
);
return
converterr
(
"integer<
n
>"
,
arg
,
msgbuf
,
bufsize
);
*
p
=
ival
;
break
;
}
...
...
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