]> granicus.if.org Git - python/commitdiff
Issue #13415: test_curses skips unencodable characters
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 28 Nov 2011 06:26:19 +0000 (07:26 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 28 Nov 2011 06:26:19 +0000 (07:26 +0100)
Lib/test/test_curses.py

index ce09855ac52b8eee0f90967d57cef1c54ba60077..21ac6089fc6c68d4776c746c897eaf5482864024 100644 (file)
@@ -267,11 +267,18 @@ def test_issue6243(stdscr):
 def test_unget_wch(stdscr):
     if not hasattr(curses, 'unget_wch'):
         return
+    import locale
+    encoding = locale.getpreferredencoding()
     for ch in ('a', '\xe9', '\u20ac', '\U0010FFFF'):
+        try:
+            ch.encode(encoding)
+        except UnicodeEncodeError:
+            continue
         try:
             curses.unget_wch(ch)
         except Exception as err:
-            raise Exception("unget_wch(%a) failed: %s" % (ch, err))
+            raise Exception("unget_wch(%a) failed with locale encoding %s: %s"
+                            % (ch, encoding, err))
         read = stdscr.get_wch()
         read = chr(read)
         if read != ch: