Skip to content

Commit 3f3ae78

Browse files
committed
Note that Locale.parse() does not accept None
Refs #977
1 parent 56071c9 commit 3f3ae78

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Deprecations & breaking changes
1818

1919
* Python 3.6 is no longer supported (:gh:`919`) - Aarni Koskela
2020
* The `get_next_timezone_transition` function is no more (:gh:`958`) - Aarni Koskela
21+
* `Locale.parse()` will no longer return `None`; it will always return a Locale or raise an exception.
22+
Passing in `None`, though technically allowed by the typing, will raise. (:gh:`966`)
2123

2224
New features
2325
~~~~~~~~~~~~

babel/core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ def parse(
279279
>>> Locale.parse(l)
280280
Locale('de', territory='DE')
281281
282+
If the `identifier` parameter is neither of these, such as `None`
283+
e.g. because a default locale identifier could not be determined,
284+
a `TypeError` is raised:
285+
286+
>>> Locale.parse(None)
287+
Traceback (most recent call last):
288+
...
289+
TypeError: ...
290+
282291
This also can perform resolving of likely subtags which it does
283292
by default. This is for instance useful to figure out the most
284293
likely locale for a territory you can use ``'und'`` as the

0 commit comments

Comments
 (0)