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
e9a5a549
Kaydet (Commit)
e9a5a549
authored
Nis 06, 2010
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix incorrect stacklevel for struct warnings. (Partial backport of r78690).
üst
f6224e79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
test_struct.py
Lib/test/test_struct.py
+24
-0
_struct.c
Modules/_struct.c
+6
-6
No files found.
Lib/test/test_struct.py
Dosyayı görüntüle @
e9a5a549
...
...
@@ -2,6 +2,7 @@ import array
import
unittest
import
struct
import
warnings
import
inspect
warnings
.
filterwarnings
(
"ignore"
,
"struct integer overflow masking is deprecated"
,
DeprecationWarning
)
...
...
@@ -106,6 +107,29 @@ class StructTest(unittest.TestCase):
self
.
assertRaises
(
struct
.
error
,
struct
.
unpack
,
'iii'
,
s
)
self
.
assertRaises
(
struct
.
error
,
struct
.
unpack
,
'i'
,
s
)
def
test_warnings_stacklevel
(
self
):
# Python versions between 2.6 and 2.6.5 were producing
# warning messages at the wrong stacklevel.
def
inner
(
fn
,
*
args
):
return
inspect
.
currentframe
()
.
f_lineno
,
fn
(
*
args
)
def
check_warning_stacklevel
(
fn
,
*
args
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
# "always" to make sure __warningregistry__ isn't affected
warnings
.
simplefilter
(
"always"
)
lineno
,
result
=
inner
(
fn
,
*
args
)
for
warn
in
w
:
self
.
assertEqual
(
warn
.
lineno
,
lineno
)
# out of range warnings
check_warning_stacklevel
(
struct
.
pack
,
'<L'
,
-
1
)
check_warning_stacklevel
(
struct
.
pack
,
'L'
,
-
1
)
check_warning_stacklevel
(
struct
.
pack
,
'<h'
,
65536
)
check_warning_stacklevel
(
struct
.
pack
,
'<l'
,
2
**
100
)
# float warnings
check_warning_stacklevel
(
struct
.
pack
,
'L'
,
3.1
)
def
test_transitiveness
(
self
):
c
=
'a'
b
=
1
...
...
Modules/_struct.c
Dosyayı görüntüle @
e9a5a549
...
...
@@ -160,7 +160,7 @@ get_long(PyObject *v, long *p)
PyObject
*
o
;
int
res
;
PyErr_Clear
();
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
FLOAT_COERCE
,
2
)
<
0
)
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
FLOAT_COERCE
,
1
)
<
0
)
return
-
1
;
o
=
PyNumber_Int
(
v
);
if
(
o
==
NULL
)
...
...
@@ -269,7 +269,7 @@ get_wrapped_long(PyObject *v, long *p)
PyObject
*
o
;
int
res
;
PyErr_Clear
();
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
FLOAT_COERCE
,
2
)
<
0
)
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
FLOAT_COERCE
,
1
)
<
0
)
return
-
1
;
o
=
PyNumber_Int
(
v
);
if
(
o
==
NULL
)
...
...
@@ -279,7 +279,7 @@ get_wrapped_long(PyObject *v, long *p)
return
res
;
}
#endif
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
INT_OVERFLOW
,
2
)
<
0
)
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
INT_OVERFLOW
,
1
)
<
0
)
return
-
1
;
wrapped
=
PyNumber_And
(
v
,
pylong_ulong_mask
);
if
(
wrapped
==
NULL
)
...
...
@@ -308,7 +308,7 @@ get_wrapped_ulong(PyObject *v, unsigned long *p)
PyObject
*
o
;
int
res
;
PyErr_Clear
();
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
FLOAT_COERCE
,
2
)
<
0
)
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
FLOAT_COERCE
,
1
)
<
0
)
return
-
1
;
o
=
PyNumber_Int
(
v
);
if
(
o
==
NULL
)
...
...
@@ -321,7 +321,7 @@ get_wrapped_ulong(PyObject *v, unsigned long *p)
wrapped
=
PyNumber_And
(
v
,
pylong_ulong_mask
);
if
(
wrapped
==
NULL
)
return
-
1
;
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
INT_OVERFLOW
,
2
)
<
0
)
{
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
INT_OVERFLOW
,
1
)
<
0
)
{
Py_DECREF
(
wrapped
);
return
-
1
;
}
...
...
@@ -417,7 +417,7 @@ _range_error(const formatdef *f, int is_unsigned)
if
(
msg
==
NULL
)
return
-
1
;
rval
=
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
PyString_AS_STRING
(
msg
),
2
);
PyString_AS_STRING
(
msg
),
1
);
Py_DECREF
(
msg
);
if
(
rval
==
0
)
return
0
;
...
...
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