Skip to content

Commit c774239

Browse files
committed
Fix test___all__ failed (env changed): locale was modified by test___all__
1 parent 9cfd9ef commit c774239

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import locale
22

3-
locale.setlocale(locale.LC_ALL, "")
4-
53

64
def fmt(value: int | float, decimals: int = 1) -> str:
75
return locale.format_string(f'%.{decimals}f', value, grouping=True)

Lib/profiling/sampling/cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import argparse
44
import importlib.util
5+
import locale
56
import os
67
import selectors
78
import socket
@@ -634,6 +635,16 @@ def _validate_args(args, parser):
634635

635636
def main():
636637
"""Main entry point for the CLI."""
638+
# Set locale for number formatting, restore on exit
639+
old_locale = locale.setlocale(locale.LC_ALL, None)
640+
locale.setlocale(locale.LC_ALL, "")
641+
try:
642+
_main()
643+
finally:
644+
locale.setlocale(locale.LC_ALL, old_locale)
645+
646+
647+
def _main():
637648
# Create the main parser
638649
parser = argparse.ArgumentParser(
639650
description=_HELP_DESCRIPTION,

0 commit comments

Comments
 (0)