PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: python-babel/babel (python)

Issue:
"ValueError: expected only letters, got u'ko-kr'"
With Babel 2.4.0 we get:
 File "/home/jenkins/workspace/openstack-manuals-tox-doc-publishlang/.tox/venv/local/lib/python2.7/site-packages/babel/core.py", line 1093, in parse_locale
"ValueError: expected only letters, got u'ko-kr'"

This comes from using "ko-kr" as locale in  http://git.openstack.org/cgit/openstack/openstack-manuals/tree/doc/install-guide/source/locale/ko_KR/LC_MESSAGES/install-guide.po#n42

We didn't have this problem with earlier Babel releases.

Other places in Babel accept the '-' like https://github.com/python-babel/babel/blob/v2.4.0/tests/test_core.py#L100 - why not here as well and break existing files this way?


Pull request:
Allow both dash and underscore separated locale identifiers in pofiles
Fixes #489
Augments #420 (08b9c5e76e19ae)

Patch:
diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py
index 3145fa3..fd40058 100644
--- a/babel/messages/catalog.py
+++ b/babel/messages/catalog.py
@@ -395,6 +395,7 @@ class Catalog(object):
             elif name == 'last-translator':
                 self.last_translator = value
             elif name == 'language':
+                value = value.replace('-', '_')
                 self.locale = Locale.parse(value)
             elif name == 'language-team':
                 self.language_team = value


Test patch:
diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py
index ebf9702..f6cd66d 100644
--- a/tests/messages/test_pofile.py
+++ b/tests/messages/test_pofile.py
@@ -36,6 +36,12 @@ msgstr ""
 "Language: en_US\n"''')
         catalog = pofile.read_po(buf, locale='de')
         self.assertEqual(Locale('en', 'US'), catalog.locale)
+        buf = StringIO(r'''
+msgid ""
+msgstr ""
+"Language: ko-KR\n"''')
+        catalog = pofile.read_po(buf, locale='de')
+        self.assertEqual(Locale('ko', 'KR'), catalog.locale)
 
     def test_preserve_domain(self):
         buf = StringIO(r'''msgid "foo"