Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sync with main
  • Loading branch information
neonene committed Feb 9, 2024
commit 36cbbdf48fb1eb5582b18ed3225f6c956d50a8a5
14 changes: 8 additions & 6 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3527,6 +3527,14 @@ dec_format_impl(PyObject *dec, PyTypeObject *cls, PyObject *fmtarg,
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(). */
Expand Down Expand Up @@ -3674,12 +3682,6 @@ dec_format_impl(PyObject *dec, PyTypeObject *cls, PyObject *fmtarg,
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);

Expand Down