mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-114678: Fix incorrect deprecation warning for 'N' specifier in Decimal format (GH-114683)
Co-authored-by: Stefan Krah <skrah@bytereef.org>
This commit is contained in:
parent
0cd9bacb8a
commit
aa3402ad45
3 changed files with 20 additions and 7 deletions
|
@ -3446,6 +3446,14 @@ dec_format(PyObject *dec, PyObject *args)
|
|||
if (fmt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (size > 0 && fmt[size-1] == 'N') {
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"Format specifier 'N' is deprecated", 1) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: If https://github.com/python/cpython/pull/29438 lands, the
|
||||
* format string manipulation below can be eliminated by enhancing
|
||||
* the forked mpd_parse_fmt_str(). */
|
||||
|
@ -3593,12 +3601,6 @@ dec_format(PyObject *dec, PyObject *args)
|
|||
if (replace_fillchar) {
|
||||
dec_replace_fillchar(decstring);
|
||||
}
|
||||
if (strchr(fmt, 'N') != NULL) {
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"Format specifier 'N' is deprecated", 1) < 0) {
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
result = PyUnicode_DecodeUTF8(decstring, size, NULL);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue