-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Escape space after comma as decimal seperator #24079
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -532,8 +532,11 @@ def _format_maybe_minus_and_locale(self, fmt, arg): | |
""" | ||
Format *arg* with *fmt*, applying Unicode minus and locale if desired. | ||
""" | ||
return self.fix_minus(locale.format_string(fmt, (arg,), True) | ||
if self._useLocale else fmt % arg) | ||
formatted = self.fix_minus(locale.format_string(fmt, (arg,), True) | ||
if self._useLocale else fmt % arg) | ||
if (self.get_useMathText()): # removed unintended space after comma | ||
formatted = formatted.replace(',', '{,}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would incorrectly also escape commas actually present in I guess a simple-ish solution could be to str.split Edit: basically return self.fix_minus(
# Escape commas introduced by format_string but not those present
# from the beginning in fmt.
",".join(locale.format_string(part, (arg,), True)
.replace(",", "{,}")
for part in fmt.split(","))
if self._useLocale else
fmt % arg) |
||
return formatted | ||
|
||
def get_useMathText(self): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will fail with "unsupported locale setting" if the locale is unavailable; at least this should be caught, and it may be better to just monkeypatch locale.format_string instead?