summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_warnings.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-10-29 22:43:41 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-10-29 22:43:41 (GMT)
commita4c704b260cc9c020d19f8417cb4524a19d0e90c (patch)
tree06614fd14300d0d8e97843b0c8626cd3bceb7b73 /Lib/test/test_warnings.py
parent602f7cf0b9afc1c7e0ab859bcfb219d20158a786 (diff)
downloadcpython-a4c704b260cc9c020d19f8417cb4524a19d0e90c.zip
cpython-a4c704b260cc9c020d19f8417cb4524a19d0e90c.tar.gz
cpython-a4c704b260cc9c020d19f8417cb4524a19d0e90c.tar.bz2
Issue #19424: Fix the warnings module to accept filename containing surrogate
characters.
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r--Lib/test/test_warnings.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 3c54c5a..52bbaf9 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -331,6 +331,18 @@ class WarnTests(BaseTest):
warning_tests.__name__ = module_name
sys.argv = argv
+ def test_warn_explicit_non_ascii_filename(self):
+ with original_warnings.catch_warnings(record=True,
+ module=self.module) as w:
+ self.module.resetwarnings()
+ self.module.filterwarnings("always", category=UserWarning)
+
+ self.module.warn_explicit("text", UserWarning, "nonascii\xe9\u20ac", 1)
+ self.assertEqual(w[-1].filename, "nonascii\xe9\u20ac")
+
+ self.module.warn_explicit("text", UserWarning, "surrogate\udc80", 1)
+ self.assertEqual(w[-1].filename, "surrogate\udc80")
+
def test_warn_explicit_type_errors(self):
# warn_explicit() should error out gracefully if it is given objects
# of the wrong types.