-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babel 2.17 regression: TypeError on Windows for locale=''
#1183
Comments
locale=''
locale=''
locale=''
Right, the problem is that the change now uses the expression |
Indeed, this is still expected to fail, but it should IMO continue to fail with |
So the change was originally made (among other reasons) so passing an empty string at the top-most API level for a locale wouldn't give you a cryptic
Even more so, we now have a better error message (though now I noticed the error message is a 1-tuple of a string, because I'm a silly goose) when the value is not ambiently available either:
I'm not 100% sure about making the latter exception a ValueError, because the value that gets eventually passed down to
Trouble is of course we don't currently know whether our end-user is explicitly passing in a silly value, or if the silly value comes from the defaulting-from-environment behavior. One option could be to make the higher-level functions do 🤔 Btw, @AA-Turner: does Sphinx's test suite explicitly/purposely unset locale-related environment variables, or should we also be wondering why no time locale gets detected on Windows? |
Not that I'm aware of. I ran the reproducer locally (Windows 11) and got identical output, so I imagine it is not specific to the test suite. A |
Could you introduce a helper function?: if locale:
return locale
if LC_TIME:
return LC_TIME
return '' if locale == '' else LC_TIME |
But then if the passed Maybe explicitly checking for an empty string as Adam is suggesting would work? |
Hi, could me and my team tackle this issue ? |
Sure, but first we need to figure out what the best course of action is here. @akx what do you think we should do? |
Reproducer:
Output:
This is minimised from Sphinx's test suite, where we've newly been seeing failures only on Windows. After much attempted debugging, I noticed Babel had a recent release. With 2.16, the error message is printed, but in 2.17 a TypeError is raised.
I think this is a regression as
locale=''
is a valid type (str
), but an invalid value. The new code useslocale or LC_TIME
, which isNone
on Windows:babel/babel/dates.py
Line 705 in b50a1d2
A
The text was updated successfully, but these errors were encountered: