mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-36381: warn when no PY_SSIZE_T_CLEAN defined (GH-12473)
We will remove int support from 3.10 or 4.0.
This commit is contained in:
parent
d60f658fc0
commit
d3c72a223a
4 changed files with 43 additions and 5 deletions
|
@ -681,7 +681,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
/* For # codes */
|
||||
#define FETCH_SIZE int *q=NULL;Py_ssize_t *q2=NULL;\
|
||||
if (flags & FLAG_SIZE_T) q2=va_arg(*p_va, Py_ssize_t*); \
|
||||
else q=va_arg(*p_va, int*);
|
||||
else { \
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning, \
|
||||
"PY_SSIZE_T_CLEAN will be required for '#' formats", 1)) { \
|
||||
return NULL; \
|
||||
} \
|
||||
q=va_arg(*p_va, int*); \
|
||||
}
|
||||
#define STORE_SIZE(s) \
|
||||
if (flags & FLAG_SIZE_T) \
|
||||
*q2=s; \
|
||||
|
@ -2591,8 +2597,13 @@ skipitem(const char **p_format, va_list *p_va, int flags)
|
|||
if (p_va != NULL) {
|
||||
if (flags & FLAG_SIZE_T)
|
||||
(void) va_arg(*p_va, Py_ssize_t *);
|
||||
else
|
||||
else {
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"PY_SSIZE_T_CLEAN will be required for '#' formats", 1)) {
|
||||
return NULL;
|
||||
}
|
||||
(void) va_arg(*p_va, int *);
|
||||
}
|
||||
}
|
||||
format++;
|
||||
} else if ((c == 's' || c == 'z' || c == 'y' || c == 'w')
|
||||
|
|
|
@ -342,8 +342,13 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
|||
++*p_format;
|
||||
if (flags & FLAG_SIZE_T)
|
||||
n = va_arg(*p_va, Py_ssize_t);
|
||||
else
|
||||
else {
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"PY_SSIZE_T_CLEAN will be required for '#' formats", 1)) {
|
||||
return NULL;
|
||||
}
|
||||
n = va_arg(*p_va, int);
|
||||
}
|
||||
}
|
||||
else
|
||||
n = -1;
|
||||
|
@ -390,8 +395,13 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
|||
++*p_format;
|
||||
if (flags & FLAG_SIZE_T)
|
||||
n = va_arg(*p_va, Py_ssize_t);
|
||||
else
|
||||
else {
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"PY_SSIZE_T_CLEAN will be required for '#' formats", 1)) {
|
||||
return NULL;
|
||||
}
|
||||
n = va_arg(*p_va, int);
|
||||
}
|
||||
}
|
||||
else
|
||||
n = -1;
|
||||
|
@ -423,8 +433,13 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
|
|||
++*p_format;
|
||||
if (flags & FLAG_SIZE_T)
|
||||
n = va_arg(*p_va, Py_ssize_t);
|
||||
else
|
||||
else {
|
||||
if (PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"PY_SSIZE_T_CLEAN will be required for '#' formats", 1)) {
|
||||
return NULL;
|
||||
}
|
||||
n = va_arg(*p_va, int);
|
||||
}
|
||||
}
|
||||
else
|
||||
n = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue