bpo-31900: Fix decimal for LC_NUMERIC != LC_CTYPE by vstinner · Pull Request #5191 · python/cpython

@vstinner

Fix decimal.Decimal formatter when the LC_NUMERIC locale encoding is
different than the LC_CTYPE encoding: reuse
_Py_GetLocaleconvNumeric() to decode localeconv() correctly, set
tempoarily setlocale() if needed.

https://bugs.python.org/issue31900

@vstinner

@skrah: So, what do you think?

skrah

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patched version introduces errors in deccheck.py. The formatting code is tricky, which is why I wasn't too enthusiastic about the patch to begin with.

I'd prefer to do nothing here.

@bedevere-bot

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@vstinner

Fix decimal.Decimal formatter when the LC_NUMERIC locale encoding is
different than the LC_CTYPE encoding: reuse
_Py_GetLocaleconvNumeric() to decode localeconv() correctly, set
tempoarily setlocale() if needed.

Add mpd_spec_t.locale field.

@vstinner

The patched version introduces errors in deccheck.py.

Oh. My type == 'n' test doesn't work, libmpdec replaces 'n' with 'g'. I don't know how I missed this.

I modified my PR to add a new mpd_spec_t.locale field.

@vstinner

I have made the requested changes; please review again.

@bedevere-bot

Thanks for making the requested changes!

@skrah: please review the changes made to this pull request.

@vstinner

@skrah: I fixed my obvious mistake. Would you mind to look again to my change? Is it now ok to merge it?

@skrah

@vstinner I'll look at it when I have time. I still think this is nice-to-have, but very low priority.