Skip to content

Commit 0aa54ca

Browse files
committed
Note that Locale.parse() does not accept None
Refs #977
1 parent 97f89b5 commit 0aa54ca

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
@@ -280,6 +280,15 @@ def parse(
280280
>>> Locale.parse(l)
281281
Locale('de', territory='DE')
282282
283+
If the `identifier` parameter is neither of these, such as `None`
284+
e.g. because a default locale identifier could not be determined,
285+
a `TypeError` is raised:
286+
287+
>>> Locale.parse(None)
288+
Traceback (most recent call last):
289+
...
290+
TypeError: ...
291+
283292
This also can perform resolving of likely subtags which it does
284293
by default. This is for instance useful to figure out the most
285294
likely locale for a territory you can use ``'und'`` as the

0 commit comments

Comments
 (0)