File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1515"""
1616from __future__ import annotations
1717
18+ import warnings
1819from collections .abc import Sequence
1920from typing import TYPE_CHECKING
2021
2324if TYPE_CHECKING :
2425 from typing_extensions import Literal
2526
26- DEFAULT_LOCALE = default_locale ()
27+
28+
29+ _DEFAULT_LOCALE = default_locale () # TODO(3.0): Remove this.
30+
31+
32+ def __getattr__ (name ):
33+ if name == "DEFAULT_LOCALE" :
34+ warnings .warn (
35+ "The babel.lists.DEFAULT_LOCALE constant is deprecated and will be removed." ,
36+ DeprecationWarning ,
37+ stacklevel = 2 ,
38+ )
39+ return _DEFAULT_LOCALE
40+ raise AttributeError (f"module { __name__ !r} has no attribute { name !r} " )
2741
2842
2943def format_list (
@@ -76,7 +90,7 @@ def format_list(
7690 :param style: the style to format the list with. See above for description.
7791 :param locale: the locale. Defaults to the system locale.
7892 """
79- locale = Locale .parse (locale or DEFAULT_LOCALE )
93+ locale = Locale .parse (locale or _DEFAULT_LOCALE )
8094 if not lst :
8195 return ''
8296 if len (lst ) == 1 :
Original file line number Diff line number Diff line change @@ -30,3 +30,8 @@ def test_issue_1098():
3030 # Translation verified using Google Translate. It would add more spacing, but the glyphs are correct.
3131 "1英尺5英寸"
3232 )
33+
34+
35+ def test_lists_default_locale_deprecation ():
36+ with pytest .warns (DeprecationWarning ):
37+ _ = lists .DEFAULT_LOCALE
You can’t perform that action at this time.
0 commit comments