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
83c9edc0
Kaydet (Commit)
83c9edc0
authored
Haz 16, 2001
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix error in comment, and in test_long_api and test_longlong_api remove
the need for the F_ERROR macro.
üst
c6057841
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
26 deletions
+21
-26
_testcapimodule.c
Modules/_testcapimodule.c
+2
-6
testcapi_long.h
Modules/testcapi_long.h
+19
-20
No files found.
Modules/_testcapimodule.c
Dosyayı görüntüle @
83c9edc0
...
@@ -202,7 +202,6 @@ raise_test_long_error(const char* msg)
...
@@ -202,7 +202,6 @@ raise_test_long_error(const char* msg)
#define F_PY_TO_S PyLong_AsLong
#define F_PY_TO_S PyLong_AsLong
#define F_U_TO_PY PyLong_FromUnsignedLong
#define F_U_TO_PY PyLong_FromUnsignedLong
#define F_PY_TO_U PyLong_AsUnsignedLong
#define F_PY_TO_U PyLong_AsUnsignedLong
#define F_ERROR raise_test_long_error
#include "testcapi_long.h"
#include "testcapi_long.h"
...
@@ -212,7 +211,7 @@ test_long_api(PyObject* self, PyObject* args)
...
@@ -212,7 +211,7 @@ test_long_api(PyObject* self, PyObject* args)
if
(
!
PyArg_ParseTuple
(
args
,
":test_long_api"
))
if
(
!
PyArg_ParseTuple
(
args
,
":test_long_api"
))
return
NULL
;
return
NULL
;
return
TESTNAME
();
return
TESTNAME
(
raise_test_long_error
);
}
}
#undef TESTNAME
#undef TESTNAME
...
@@ -221,7 +220,6 @@ test_long_api(PyObject* self, PyObject* args)
...
@@ -221,7 +220,6 @@ test_long_api(PyObject* self, PyObject* args)
#undef F_PY_TO_S
#undef F_PY_TO_S
#undef F_U_TO_PY
#undef F_U_TO_PY
#undef F_PY_TO_U
#undef F_PY_TO_U
#undef F_ERROR
#ifdef HAVE_LONG_LONG
#ifdef HAVE_LONG_LONG
...
@@ -237,7 +235,6 @@ raise_test_longlong_error(const char* msg)
...
@@ -237,7 +235,6 @@ raise_test_longlong_error(const char* msg)
#define F_PY_TO_S PyLong_AsLongLong
#define F_PY_TO_S PyLong_AsLongLong
#define F_U_TO_PY PyLong_FromUnsignedLongLong
#define F_U_TO_PY PyLong_FromUnsignedLongLong
#define F_PY_TO_U PyLong_AsUnsignedLongLong
#define F_PY_TO_U PyLong_AsUnsignedLongLong
#define F_ERROR raise_test_longlong_error
#include "testcapi_long.h"
#include "testcapi_long.h"
...
@@ -247,7 +244,7 @@ test_longlong_api(PyObject* self, PyObject* args)
...
@@ -247,7 +244,7 @@ test_longlong_api(PyObject* self, PyObject* args)
if
(
!
PyArg_ParseTuple
(
args
,
":test_longlong_api"
))
if
(
!
PyArg_ParseTuple
(
args
,
":test_longlong_api"
))
return
NULL
;
return
NULL
;
return
TESTNAME
();
return
TESTNAME
(
raise_test_longlong_error
);
}
}
#undef TESTNAME
#undef TESTNAME
...
@@ -256,7 +253,6 @@ test_longlong_api(PyObject* self, PyObject* args)
...
@@ -256,7 +253,6 @@ test_longlong_api(PyObject* self, PyObject* args)
#undef F_PY_TO_S
#undef F_PY_TO_S
#undef F_U_TO_PY
#undef F_U_TO_PY
#undef F_PY_TO_U
#undef F_PY_TO_U
#undef F_ERROR
#endif
/* ifdef HAVE_LONG_LONG */
#endif
/* ifdef HAVE_LONG_LONG */
...
...
Modules/testcapi_long.h
Dosyayı görüntüle @
83c9edc0
...
@@ -4,12 +4,11 @@
...
@@ -4,12 +4,11 @@
F_S_TO_PY convert signed to pylong; TYPENAME -> PyObject*
F_S_TO_PY convert signed to pylong; TYPENAME -> PyObject*
F_PY_TO_S convert pylong to signed; PyObject* -> TYPENAME
F_PY_TO_S convert pylong to signed; PyObject* -> TYPENAME
F_U_TO_PY convert unsigned to pylong; unsigned TYPENAME -> PyObject*
F_U_TO_PY convert unsigned to pylong; unsigned TYPENAME -> PyObject*
F_PY_TO_U convert pylong to unsigned; PyObject* -> TypeError
F_PY_TO_U convert pylong to unsigned; PyObject* -> unsigned TYPENAME
F_ERROR error-report function; char* -> PyObject* (returns NULL)
*/
*/
static
PyObject
*
static
PyObject
*
TESTNAME
()
TESTNAME
(
PyObject
*
error
(
const
char
*
)
)
{
{
const
int
NBITS
=
sizeof
(
TYPENAME
)
*
8
;
const
int
NBITS
=
sizeof
(
TYPENAME
)
*
8
;
unsigned
TYPENAME
base
;
unsigned
TYPENAME
base
;
...
@@ -45,30 +44,30 @@ TESTNAME()
...
@@ -45,30 +44,30 @@ TESTNAME()
pyresult
=
F_U_TO_PY
(
uin
);
pyresult
=
F_U_TO_PY
(
uin
);
if
(
pyresult
==
NULL
)
if
(
pyresult
==
NULL
)
return
F_ERROR
(
return
error
(
"unsigned unexpected null result"
);
"unsigned unexpected null result"
);
uout
=
F_PY_TO_U
(
pyresult
);
uout
=
F_PY_TO_U
(
pyresult
);
if
(
uout
==
(
unsigned
TYPENAME
)
-
1
&&
PyErr_Occurred
())
if
(
uout
==
(
unsigned
TYPENAME
)
-
1
&&
PyErr_Occurred
())
return
F_ERROR
(
return
error
(
"unsigned unexpected -1 result"
);
"unsigned unexpected -1 result"
);
if
(
uout
!=
uin
)
if
(
uout
!=
uin
)
return
F_ERROR
(
return
error
(
"unsigned output != input"
);
"unsigned output != input"
);
UNBIND
(
pyresult
);
UNBIND
(
pyresult
);
in
=
(
TYPENAME
)
uin
;
in
=
(
TYPENAME
)
uin
;
pyresult
=
F_S_TO_PY
(
in
);
pyresult
=
F_S_TO_PY
(
in
);
if
(
pyresult
==
NULL
)
if
(
pyresult
==
NULL
)
return
F_ERROR
(
return
error
(
"signed unexpected null result"
);
"signed unexpected null result"
);
out
=
F_PY_TO_S
(
pyresult
);
out
=
F_PY_TO_S
(
pyresult
);
if
(
out
==
(
TYPENAME
)
-
1
&&
PyErr_Occurred
())
if
(
out
==
(
TYPENAME
)
-
1
&&
PyErr_Occurred
())
return
F_ERROR
(
return
error
(
"signed unexpected -1 result"
);
"signed unexpected -1 result"
);
if
(
out
!=
in
)
if
(
out
!=
in
)
return
F_ERROR
(
return
error
(
"signed output != input"
);
"signed output != input"
);
UNBIND
(
pyresult
);
UNBIND
(
pyresult
);
}
}
...
@@ -85,18 +84,18 @@ TESTNAME()
...
@@ -85,18 +84,18 @@ TESTNAME()
one
=
PyLong_FromLong
(
1
);
one
=
PyLong_FromLong
(
1
);
if
(
one
==
NULL
)
if
(
one
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyLong_FromLong"
);
"unexpected NULL from PyLong_FromLong"
);
/* Unsigned complains about -1? */
/* Unsigned complains about -1? */
x
=
PyNumber_Negative
(
one
);
x
=
PyNumber_Negative
(
one
);
if
(
x
==
NULL
)
if
(
x
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyNumber_Negative"
);
"unexpected NULL from PyNumber_Negative"
);
uout
=
F_PY_TO_U
(
x
);
uout
=
F_PY_TO_U
(
x
);
if
(
uout
!=
(
unsigned
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
if
(
uout
!=
(
unsigned
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
return
F_ERROR
(
return
error
(
"PyLong_AsUnsignedXXX(-1) didn't complain"
);
"PyLong_AsUnsignedXXX(-1) didn't complain"
);
PyErr_Clear
();
PyErr_Clear
();
UNBIND
(
x
);
UNBIND
(
x
);
...
@@ -104,18 +103,18 @@ TESTNAME()
...
@@ -104,18 +103,18 @@ TESTNAME()
/* Unsigned complains about 2**NBITS? */
/* Unsigned complains about 2**NBITS? */
y
=
PyLong_FromLong
((
long
)
NBITS
);
y
=
PyLong_FromLong
((
long
)
NBITS
);
if
(
y
==
NULL
)
if
(
y
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyLong_FromLong"
);
"unexpected NULL from PyLong_FromLong"
);
x
=
PyNumber_Lshift
(
one
,
y
);
/* 1L << NBITS, == 2**NBITS */
x
=
PyNumber_Lshift
(
one
,
y
);
/* 1L << NBITS, == 2**NBITS */
UNBIND
(
y
);
UNBIND
(
y
);
if
(
x
==
NULL
)
if
(
x
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyNumber_Lshift"
);
"unexpected NULL from PyNumber_Lshift"
);
uout
=
F_PY_TO_U
(
x
);
uout
=
F_PY_TO_U
(
x
);
if
(
uout
!=
(
unsigned
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
if
(
uout
!=
(
unsigned
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
return
F_ERROR
(
return
error
(
"PyLong_AsUnsignedXXX(2**NBITS) didn't "
"PyLong_AsUnsignedXXX(2**NBITS) didn't "
"complain"
);
"complain"
);
PyErr_Clear
();
PyErr_Clear
();
...
@@ -125,12 +124,12 @@ TESTNAME()
...
@@ -125,12 +124,12 @@ TESTNAME()
y
=
PyNumber_Rshift
(
x
,
one
);
/* 2**(NBITS-1) */
y
=
PyNumber_Rshift
(
x
,
one
);
/* 2**(NBITS-1) */
UNBIND
(
x
);
UNBIND
(
x
);
if
(
y
==
NULL
)
if
(
y
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyNumber_Rshift"
);
"unexpected NULL from PyNumber_Rshift"
);
out
=
F_PY_TO_S
(
y
);
out
=
F_PY_TO_S
(
y
);
if
(
out
!=
(
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
if
(
out
!=
(
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
return
F_ERROR
(
return
error
(
"PyLong_AsXXX(2**(NBITS-1)) didn't "
"PyLong_AsXXX(2**(NBITS-1)) didn't "
"complain"
);
"complain"
);
PyErr_Clear
();
PyErr_Clear
();
...
@@ -140,18 +139,18 @@ TESTNAME()
...
@@ -140,18 +139,18 @@ TESTNAME()
x
=
PyNumber_Negative
(
y
);
/* -(2**(NBITS-1)) */
x
=
PyNumber_Negative
(
y
);
/* -(2**(NBITS-1)) */
UNBIND
(
y
);
UNBIND
(
y
);
if
(
x
==
NULL
)
if
(
x
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyNumber_Negative"
);
"unexpected NULL from PyNumber_Negative"
);
y
=
PyNumber_Subtract
(
x
,
one
);
/* -(2**(NBITS-1))-1 */
y
=
PyNumber_Subtract
(
x
,
one
);
/* -(2**(NBITS-1))-1 */
UNBIND
(
x
);
UNBIND
(
x
);
if
(
y
==
NULL
)
if
(
y
==
NULL
)
return
F_ERROR
(
return
error
(
"unexpected NULL from PyNumber_Subtract"
);
"unexpected NULL from PyNumber_Subtract"
);
out
=
F_PY_TO_S
(
y
);
out
=
F_PY_TO_S
(
y
);
if
(
out
!=
(
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
if
(
out
!=
(
TYPENAME
)
-
1
||
!
PyErr_Occurred
())
return
F_ERROR
(
return
error
(
"PyLong_AsXXX(-2**(NBITS-1)-1) didn't "
"PyLong_AsXXX(-2**(NBITS-1)-1) didn't "
"complain"
);
"complain"
);
PyErr_Clear
();
PyErr_Clear
();
...
...
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