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
4182a755
Kaydet (Commit)
4182a755
authored
May 30, 2006
tarafından
Bob Ippolito
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Change wrapping terminology to overflow masking
üst
93eff6fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
21 deletions
+21
-21
test_struct.py
Lib/test/test_struct.py
+3
-3
_struct.c
Modules/_struct.c
+18
-18
No files found.
Lib/test/test_struct.py
Dosyayı görüntüle @
4182a755
...
...
@@ -15,10 +15,10 @@ try:
import
_struct
except
ImportError
:
PY_STRUCT_RANGE_CHECKING
=
0
PY_STRUCT_
WRAPP
ING
=
1
PY_STRUCT_
OVERFLOW_MASK
ING
=
1
else
:
PY_STRUCT_RANGE_CHECKING
=
getattr
(
_struct
,
'_PY_STRUCT_RANGE_CHECKING'
,
0
)
PY_STRUCT_
WRAPPING
=
getattr
(
_struct
,
'_PY_STRUCT_WRAPP
ING'
,
0
)
PY_STRUCT_
OVERFLOW_MASKING
=
getattr
(
_struct
,
'_PY_STRUCT_OVERFLOW_MASK
ING'
,
0
)
def
string_reverse
(
s
):
chars
=
list
(
s
)
...
...
@@ -62,7 +62,7 @@ def deprecated_err(func, *args):
except
(
struct
.
error
,
TypeError
):
pass
except
DeprecationWarning
:
if
not
PY_STRUCT_
WRAPP
ING
:
if
not
PY_STRUCT_
OVERFLOW_MASK
ING
:
raise
TestFailed
,
"
%
s
%
s expected to raise struct.error"
%
(
func
.
__name__
,
args
)
else
:
...
...
Modules/_struct.c
Dosyayı görüntüle @
4182a755
...
...
@@ -17,16 +17,16 @@ static PyTypeObject PyStructType;
typedef
int
Py_ssize_t
;
#endif
/* If PY_STRUCT_
WRAPP
ING is defined, the struct module will wrap all input
/* If PY_STRUCT_
OVERFLOW_MASK
ING is defined, the struct module will wrap all input
numbers for explicit endians such that they fit in the given type, much
like explicit casting in C. A warning will be raised if the number did
not originally fit within the range of the requested type. If it is
not defined, then all range errors and overflow will be struct.error
exceptions. */
#define PY_STRUCT_
WRAPP
ING 1
#define PY_STRUCT_
OVERFLOW_MASK
ING 1
#ifdef PY_STRUCT_
WRAPP
ING
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
static
PyObject
*
pylong_ulong_mask
=
NULL
;
static
PyObject
*
pyint_zero
=
NULL
;
#endif
...
...
@@ -209,7 +209,7 @@ get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p)
#endif
#ifdef PY_STRUCT_
WRAPP
ING
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
/* Helper routine to get a Python integer and raise the appropriate error
if it isn't one */
...
...
@@ -222,7 +222,7 @@ get_wrapped_long(PyObject *v, long *p)
PyObject
*
wrapped
;
long
x
;
PyErr_Clear
();
if
(
PyErr_Warn
(
PyExc_DeprecationWarning
,
"struct integer
wrapp
ing is deprecated"
)
<
0
)
if
(
PyErr_Warn
(
PyExc_DeprecationWarning
,
"struct integer
overflow mask
ing is deprecated"
)
<
0
)
return
-
1
;
wrapped
=
PyNumber_And
(
v
,
pylong_ulong_mask
);
if
(
wrapped
==
NULL
)
...
...
@@ -249,7 +249,7 @@ get_wrapped_ulong(PyObject *v, unsigned long *p)
wrapped
=
PyNumber_And
(
v
,
pylong_ulong_mask
);
if
(
wrapped
==
NULL
)
return
-
1
;
if
(
PyErr_Warn
(
PyExc_DeprecationWarning
,
"struct integer
wrapp
ing is deprecated"
)
<
0
)
{
if
(
PyErr_Warn
(
PyExc_DeprecationWarning
,
"struct integer
overflow mask
ing is deprecated"
)
<
0
)
{
Py_DECREF
(
wrapped
);
return
-
1
;
}
...
...
@@ -330,7 +330,7 @@ _range_error(const formatdef *f, int is_unsigned)
f
->
format
,
largest
);
}
#ifdef PY_STRUCT_
WRAPP
ING
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
{
PyObject
*
ptype
,
*
pvalue
,
*
ptraceback
;
PyObject
*
msg
;
...
...
@@ -819,7 +819,7 @@ bp_int(char *p, PyObject *v, const formatdef *f)
else
if
((
i
==
4
)
&&
(
x
<
-
2147483648L
||
x
>
2147483647L
))
RANGE_ERROR
(
x
,
f
,
0
,
0xffffffffL
);
#endif
#ifdef PY_STRUCT_
WRAPP
ING
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
else
if
((
i
==
1
)
&&
(
x
<
-
128
||
x
>
127
))
RANGE_ERROR
(
x
,
f
,
0
,
0xffL
);
#endif
...
...
@@ -910,8 +910,8 @@ bp_double(char *p, PyObject *v, const formatdef *f)
static
formatdef
bigendian_table
[]
=
{
{
'x'
,
1
,
0
,
NULL
},
#ifdef PY_STRUCT_
WRAPP
ING
/* Native packers do range checking without
wrapp
ing. */
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
/* Native packers do range checking without
overflow mask
ing. */
{
'b'
,
1
,
0
,
nu_byte
,
bp_int
},
{
'B'
,
1
,
0
,
nu_ubyte
,
bp_uint
},
#else
...
...
@@ -1037,7 +1037,7 @@ lp_int(char *p, PyObject *v, const formatdef *f)
else
if
((
i
==
4
)
&&
(
x
<
-
2147483648L
||
x
>
2147483647L
))
RANGE_ERROR
(
x
,
f
,
0
,
0xffffffffL
);
#endif
#ifdef PY_STRUCT_
WRAPP
ING
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
else
if
((
i
==
1
)
&&
(
x
<
-
128
||
x
>
127
))
RANGE_ERROR
(
x
,
f
,
0
,
0xffL
);
#endif
...
...
@@ -1128,8 +1128,8 @@ lp_double(char *p, PyObject *v, const formatdef *f)
static
formatdef
lilendian_table
[]
=
{
{
'x'
,
1
,
0
,
NULL
},
#ifdef PY_STRUCT_
WRAPP
ING
/* Native packers do range checking without
wrapp
ing. */
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
/* Native packers do range checking without
overflow mask
ing. */
{
'b'
,
1
,
0
,
nu_byte
,
lp_int
},
{
'B'
,
1
,
0
,
nu_ubyte
,
lp_uint
},
#else
...
...
@@ -1740,7 +1740,7 @@ init_struct(void)
if
(
PyType_Ready
(
&
PyStructType
)
<
0
)
return
;
#ifdef PY_STRUCT_
WRAPP
ING
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
if
(
pyint_zero
==
NULL
)
{
pyint_zero
=
PyInt_FromLong
(
0
);
if
(
pyint_zero
==
NULL
)
...
...
@@ -1757,8 +1757,8 @@ init_struct(void)
}
#else
/* This speed trick can't be used until
wrapp
ing goes away, because
native endian always raises exceptions instead of
wrapp
ing. */
/* This speed trick can't be used until
overflow mask
ing goes away, because
native endian always raises exceptions instead of
overflow mask
ing. */
/* Check endian and swap in faster functions */
{
...
...
@@ -1814,7 +1814,7 @@ init_struct(void)
PyModule_AddObject
(
m
,
"Struct"
,
(
PyObject
*
)
&
PyStructType
);
PyModule_AddIntConstant
(
m
,
"_PY_STRUCT_RANGE_CHECKING"
,
1
);
#ifdef PY_STRUCT_
WRAPP
ING
PyModule_AddIntConstant
(
m
,
"_PY_STRUCT_
WRAPP
ING"
,
1
);
#ifdef PY_STRUCT_
OVERFLOW_MASK
ING
PyModule_AddIntConstant
(
m
,
"_PY_STRUCT_
OVERFLOW_MASK
ING"
,
1
);
#endif
}
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