]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Note that `Locale.parse()` does not accept `None`
authorAarni Koskela <akx@iki.fi>
Wed, 1 Mar 2023 06:25:31 +0000 (08:25 +0200)
committerAarni Koskela <akx@iki.fi>
Wed, 1 Mar 2023 18:03:40 +0000 (20:03 +0200)
Refs #977

CHANGES.rst
babel/core.py

index 3a8f1d25b99735195daf069e0785eeae782cb769..a8dcc7d4a75714034960570e4dbd85e605bf245b 100644 (file)
@@ -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
 ~~~~~~~~~~~~
index 4cceba933c82be9fcbc0452cfc735dca215506b6..ba8a621fad7b4bf86cd949fef791ed845a9c0071 100644 (file)
@@ -280,6 +280,15 @@ class Locale:
         >>> 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