8000 Fix indention of run_with_locale() · python/cpython@a364eba · GitHub
[go: up one dir, main page]

Skip to content

Commit a364eba

Browse files
committed
Fix indention of run_with_locale()
1 parent 0e06f2c commit a364eba

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Lib/test/support/__init__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -774,29 +774,29 @@ def check_sizeof(test, o, size):
774774

775775
@contextlib.contextmanager
776776
def run_with_locale(catstr, *locales):
777+
try:
778+
import locale
779+
category = getattr(locale, catstr)
780+
orig_locale = locale.setlocale(category)
781+
except AttributeError:
782+
# if the test author gives us an invalid category string
783+
raise
784+
except:
785+
# cannot retrieve original locale, so do nothing
786+
locale = orig_locale = None
787+
else:
788+
for loc in locales:
777789
try:
778-
import locale
779-
category = getattr(locale, catstr)
780-
orig_locale = locale.setlocale(category)
781-
except AttributeError:
782-
# if the test author gives us an invalid category string
783-
raise
790+
locale.setlocale(category, loc)
791+
break
784792
except:
785-
# cannot retrieve original locale, so do nothing
786-
locale = orig_locale = None
787-
else:
788-
for loc in locales:
789-
try:
790-
locale.setlocale(category, loc)
791-
break
792-
except:
793-
pass
793+
pass
794794

795-
try:
796-
yield
797-
finally:
798-
if locale and orig_locale:
799-
locale.setlocale(category, orig_locale)
795+
try:
796+
yield
797+
finally:
798+
if locale and orig_locale:
799+
locale.setlocale(category, orig_locale)
800800

801801
#=======================================================================
802802
# Decorator for running a function in a specific timezone, correctly

0 commit comments

Comments
 (0)
0