Skip to content

Commit

Permalink
Note that Locale.parse() does not accept None
Browse files Browse the repository at this point in the history
Refs #977
  • Loading branch information
akx committed Mar 1, 2023
1 parent 97f89b5 commit 0aa54ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Deprecations & breaking changes

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

New features
~~~~~~~~~~~~
Expand Down
9 changes: 9 additions & 0 deletions babel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ def parse(
>>> Locale.parse(l)
Locale('de', territory='DE')
If the `identifier` parameter is neither of these, such as `None`
e.g. because a default locale identifier could not be determined,
a `TypeError` is raised:
>>> Locale.parse(None)
Traceback (most recent call last):
...
TypeError: ...
This also can perform resolving of likely subtags which it does
by default. This is for instance useful to figure out the most
likely locale for a territory you can use ``'und'`` as the
Expand Down

0 comments on commit 0aa54ca

Please sign in to comment.