nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: python-babel/babel
Pull request #1184 (2025-02-03 09:01:57)

Fix formatting for "Empty locale identifier" exception added in #1164
Refs #1183.

## Before

```
$ env LANG= LC_TIME= uvx --from=babel==2.17.0 --python=3.13 python ~/Desktop/reproducer.py
[...]
TypeError: ("Empty locale identifier value: None\n\nIf you didn't explicitly pass an empty value to a Babel function, this could be caused by there being no suitable locale environment variables for the API you tried to use.",)
```

## After

```
$ env LANG= LC_TIME= python ~/Desktop/reproducer.py
[...]
TypeError: Empty locale identifier value: None

If you didn't explicitly pass an empty value to a Babel function, this could be caused by there being no suitable locale environment variables for the API you tried to use.
```


Patch:
diff --git a/babel/core.py b/babel/core.py
index 5762bbe..7386fb3 100644
--- a/babel/core.py
+++ b/babel/core.py
@@ -343,7 +343,7 @@ class Locale:
                 f"Empty locale identifier value: {identifier!r}\n\n"
                 f"If you didn't explicitly pass an empty value to a Babel function, "
                 f"this could be caused by there being no suitable locale environment "
-                f"variables for the API you tried to use.",
+                f"variables for the API you tried to use."
             )
             if isinstance(identifier, str):
                 raise ValueError(msg)  # `parse_locale` would raise a ValueError, so let's do that here


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index aaf95a1..8c215de 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -395,8 +395,9 @@ def test_language_alt_official_not_used():
 
 
 def test_locale_parse_empty():
-    with pytest.raises(ValueError, match="Empty"):
+    with pytest.raises(ValueError, match="Empty") as ei:
         Locale.parse("")
+    assert isinstance(ei.value.args[0], str)
     with pytest.raises(TypeError, match="Empty"):
         Locale.parse(None)
     with pytest.raises(TypeError, match="Empty"):