summaryrefslogtreecommitdiff
path: root/dev-python/urwid/files/urwid-2.1.1-ignore-resetting-to-invalid-locale.patch
blob: 61549a50d0875dd212ae687cd9689f42c909d0e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From fd010f8336407ad1a42522b424d2ea7b7800ebc4 Mon Sep 17 00:00:00 2001
From: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Fri, 26 Jun 2020 22:26:23 +0200
Subject: [PATCH] Ignore resetting to invalid locale (Closes: #377)

Resetting the locale was introduced in 5dcf236, before that an invalid
locale was ignored. Restore the old behavior insofar that only valid
locales are restored.
This fixes the unit tests of scottkosty/vit with unset LANG.
---
 urwid/util.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/urwid/util.py b/urwid/util.py
index 17c049d..acd62f6 100644
--- a/urwid/util.py
+++ b/urwid/util.py
@@ -55,7 +55,10 @@ def detect_encoding():
         else:
             raise
     finally:
-        locale.setlocale(locale.LC_ALL, initial)
+        try:
+            locale.setlocale(locale.LC_ALL, initial)
+        except locale.Error:
+            pass
 
 if 'detected_encoding' not in locals():
     detected_encoding = detect_encoding()
-- 
2.26.2