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
63a6a6fd
Kaydet (Commit)
63a6a6fd
authored
May 03, 2015
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge 3.4 (#24096)
üst
4b7b82f1
8c59816b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
10 deletions
+42
-10
test_warnings.py
Lib/test/test_warnings.py
+12
-0
NEWS
Misc/NEWS
+3
-0
_warnings.c
Python/_warnings.c
+27
-10
No files found.
Lib/test/test_warnings.py
Dosyayı görüntüle @
63a6a6fd
...
...
@@ -247,6 +247,18 @@ class FilterTests(BaseTest):
self
.
assertEqual
(
str
(
w
[
-
1
]
.
message
),
text
)
self
.
assertTrue
(
w
[
-
1
]
.
category
is
UserWarning
)
def
test_mutate_filter_list
(
self
):
class
X
:
def
match
(
self
,
a
):
L
[:]
=
[]
L
=
[(
"default"
,
X
(),
UserWarning
,
X
(),
0
)
for
i
in
range
(
2
)]
with
original_warnings
.
catch_warnings
(
record
=
True
,
module
=
self
.
module
)
as
w
:
self
.
module
.
filters
=
L
self
.
module
.
warn_explicit
(
UserWarning
(
"b"
),
None
,
"f.py"
,
42
)
self
.
assertEqual
(
str
(
w
[
-
1
]
.
message
),
"b"
)
class
CFilterTests
(
FilterTests
,
unittest
.
TestCase
):
module
=
c_warnings
...
...
Misc/NEWS
Dosyayı görüntüle @
63a6a6fd
...
...
@@ -10,6 +10,9 @@ Release date: 2015-04-24
Core and Builtins
-----------------
- Issue #24096: Make warnings.warn_explicit more robust against mutation of the
warnings.filters list.
- Issue #23996: Avoid a crash when a delegated generator raises an
unnormalized StopIteration exception. Patch by Stefan Behnel.
...
...
Python/_warnings.c
Dosyayı görüntüle @
63a6a6fd
...
...
@@ -101,7 +101,7 @@ get_default_action(void)
}
/* The item is a
borrowed
reference. */
/* The item is a
new
reference. */
static
PyObject
*
get_filter
(
PyObject
*
category
,
PyObject
*
text
,
Py_ssize_t
lineno
,
PyObject
*
module
,
PyObject
**
item
)
...
...
@@ -132,14 +132,15 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
Py_ssize_t
ln
;
int
is_subclass
,
good_msg
,
good_mod
;
tmp_item
=
*
item
=
PyList_GET_ITEM
(
_filters
,
i
);
if
(
PyTuple_Size
(
tmp_item
)
!=
5
)
{
tmp_item
=
PyList_GET_ITEM
(
_filters
,
i
);
if
(
!
PyTuple_Check
(
tmp_item
)
||
PyTuple_GET_SIZE
(
tmp_item
)
!=
5
)
{
PyErr_Format
(
PyExc_ValueError
,
MODULE_NAME
".filters item %zd isn't a 5-tuple"
,
i
);
return
NULL
;
}
/* Python code: action, msg, cat, mod, ln = item */
Py_INCREF
(
tmp_item
);
action
=
PyTuple_GET_ITEM
(
tmp_item
,
0
);
msg
=
PyTuple_GET_ITEM
(
tmp_item
,
1
);
cat
=
PyTuple_GET_ITEM
(
tmp_item
,
2
);
...
...
@@ -147,28 +148,43 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
ln_obj
=
PyTuple_GET_ITEM
(
tmp_item
,
4
);
good_msg
=
check_matched
(
msg
,
text
);
if
(
good_msg
==
-
1
)
if
(
good_msg
==
-
1
)
{
Py_DECREF
(
tmp_item
);
return
NULL
;
}
good_mod
=
check_matched
(
mod
,
module
);
if
(
good_mod
==
-
1
)
if
(
good_mod
==
-
1
)
{
Py_DECREF
(
tmp_item
);
return
NULL
;
}
is_subclass
=
PyObject_IsSubclass
(
category
,
cat
);
if
(
is_subclass
==
-
1
)
if
(
is_subclass
==
-
1
)
{
Py_DECREF
(
tmp_item
);
return
NULL
;
}
ln
=
PyLong_AsSsize_t
(
ln_obj
);
if
(
ln
==
-
1
&&
PyErr_Occurred
())
if
(
ln
==
-
1
&&
PyErr_Occurred
())
{
Py_DECREF
(
tmp_item
);
return
NULL
;
}
if
(
good_msg
&&
is_subclass
&&
good_mod
&&
(
ln
==
0
||
lineno
==
ln
))
if
(
good_msg
&&
is_subclass
&&
good_mod
&&
(
ln
==
0
||
lineno
==
ln
))
{
*
item
=
tmp_item
;
return
action
;
}
Py_DECREF
(
tmp_item
);
}
action
=
get_default_action
();
if
(
action
!=
NULL
)
if
(
action
!=
NULL
)
{
Py_INCREF
(
Py_None
);
*
item
=
Py_None
;
return
action
;
}
PyErr_SetString
(
PyExc_ValueError
,
MODULE_NAME
".defaultaction not found"
);
...
...
@@ -349,7 +365,7 @@ warn_explicit(PyObject *category, PyObject *message,
PyObject
*
module
,
PyObject
*
registry
,
PyObject
*
sourceline
)
{
PyObject
*
key
=
NULL
,
*
text
=
NULL
,
*
result
=
NULL
,
*
lineno_obj
=
NULL
;
PyObject
*
item
=
Py_None
;
PyObject
*
item
=
NULL
;
PyObject
*
action
;
int
rc
;
...
...
@@ -488,6 +504,7 @@ warn_explicit(PyObject *category, PyObject *message,
Py_INCREF
(
result
);
cleanup:
Py_XDECREF
(
item
);
Py_XDECREF
(
key
);
Py_XDECREF
(
text
);
Py_XDECREF
(
lineno_obj
);
...
...
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