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
252033d5
Kaydet (Commit)
252033d5
authored
Eyl 11, 2017
tarafından
Oren Milman
Kaydeden (comit)
Serhiy Storchaka
Eyl 11, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (#3485)
üst
3866d9bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
__init__.py
Lib/test/test_warnings/__init__.py
+11
-0
2017-09-11-08-50-41.bpo-31411.HZz82I.rst
...ore and Builtins/2017-09-11-08-50-41.bpo-31411.HZz82I.rst
+2
-0
_warnings.c
Python/_warnings.c
+7
-1
No files found.
Lib/test/test_warnings/__init__.py
Dosyayı görüntüle @
252033d5
...
@@ -794,6 +794,17 @@ class _WarningsTests(BaseTest, unittest.TestCase):
...
@@ -794,6 +794,17 @@ class _WarningsTests(BaseTest, unittest.TestCase):
self
.
assertNotIn
(
b
'Warning!'
,
stderr
)
self
.
assertNotIn
(
b
'Warning!'
,
stderr
)
self
.
assertNotIn
(
b
'Error'
,
stderr
)
self
.
assertNotIn
(
b
'Error'
,
stderr
)
@support.cpython_only
def
test_issue31411
(
self
):
# warn_explicit() shouldn't raise a SystemError in case
# warnings.onceregistry isn't a dictionary.
wmod
=
self
.
module
with
original_warnings
.
catch_warnings
(
module
=
wmod
):
wmod
.
filterwarnings
(
'once'
)
with
support
.
swap_attr
(
wmod
,
'onceregistry'
,
None
):
with
self
.
assertRaises
(
TypeError
):
wmod
.
warn_explicit
(
'foo'
,
Warning
,
'bar'
,
1
,
registry
=
None
)
class
WarningsDisplayTests
(
BaseTest
):
class
WarningsDisplayTests
(
BaseTest
):
...
...
Misc/NEWS.d/next/Core and Builtins/2017-09-11-08-50-41.bpo-31411.HZz82I.rst
0 → 100644
Dosyayı görüntüle @
252033d5
Raise a TypeError instead of SystemError in case warnings.onceregistry is
not a dictionary. Patch by Oren Milman.
Python/_warnings.c
Dosyayı görüntüle @
252033d5
...
@@ -86,6 +86,12 @@ get_once_registry(void)
...
@@ -86,6 +86,12 @@ get_once_registry(void)
return
NULL
;
return
NULL
;
return
_PyRuntime
.
warnings
.
once_registry
;
return
_PyRuntime
.
warnings
.
once_registry
;
}
}
if
(
!
PyDict_Check
(
registry
))
{
PyErr_SetString
(
PyExc_TypeError
,
"warnings.onceregistry must be a dict"
);
Py_DECREF
(
registry
);
return
NULL
;
}
Py_DECREF
(
_PyRuntime
.
warnings
.
once_registry
);
Py_DECREF
(
_PyRuntime
.
warnings
.
once_registry
);
_PyRuntime
.
warnings
.
once_registry
=
registry
;
_PyRuntime
.
warnings
.
once_registry
=
registry
;
return
registry
;
return
registry
;
...
@@ -437,7 +443,7 @@ warn_explicit(PyObject *category, PyObject *message,
...
@@ -437,7 +443,7 @@ warn_explicit(PyObject *category, PyObject *message,
Py_RETURN_NONE
;
Py_RETURN_NONE
;
if
(
registry
&&
!
PyDict_Check
(
registry
)
&&
(
registry
!=
Py_None
))
{
if
(
registry
&&
!
PyDict_Check
(
registry
)
&&
(
registry
!=
Py_None
))
{
PyErr_SetString
(
PyExc_TypeError
,
"'registry' must be a dict"
);
PyErr_SetString
(
PyExc_TypeError
,
"'registry' must be a dict
or None
"
);
return
NULL
;
return
NULL
;
}
}
...
...
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