mirror of
https://github.com/python/cpython.git
synced 2025-12-11 19:40:17 +00:00
doubletounicode(), longtounicode():
Py_SAFE_DOWNCAST can evaluate its first argument multiple times in a debug build. This caused two distinct assert- failures in test_unicode run under a debug build. Rewrote the code in trivial ways so that multiple evaluation of the first argument doesn't hurt.
This commit is contained in:
parent
c7f6cf6247
commit
15231548d2
1 changed files with 8 additions and 4 deletions
|
|
@ -6601,17 +6601,21 @@ strtounicode(Py_UNICODE *buffer, const char *charbuffer)
|
||||||
static int
|
static int
|
||||||
doubletounicode(Py_UNICODE *buffer, size_t len, const char *format, double x)
|
doubletounicode(Py_UNICODE *buffer, size_t len, const char *format, double x)
|
||||||
{
|
{
|
||||||
|
Py_ssize_t result;
|
||||||
|
|
||||||
PyOS_ascii_formatd((char *)buffer, len, format, x);
|
PyOS_ascii_formatd((char *)buffer, len, format, x);
|
||||||
return Py_SAFE_DOWNCAST(strtounicode(buffer, (char *)buffer),
|
result = strtounicode(buffer, (char *)buffer);
|
||||||
Py_ssize_t, int);
|
return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
longtounicode(Py_UNICODE *buffer, size_t len, const char *format, long x)
|
longtounicode(Py_UNICODE *buffer, size_t len, const char *format, long x)
|
||||||
{
|
{
|
||||||
|
Py_ssize_t result;
|
||||||
|
|
||||||
PyOS_snprintf((char *)buffer, len, format, x);
|
PyOS_snprintf((char *)buffer, len, format, x);
|
||||||
return Py_SAFE_DOWNCAST(strtounicode(buffer, (char *)buffer),
|
result = strtounicode(buffer, (char *)buffer);
|
||||||
Py_ssize_t, int);
|
return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX To save some code duplication, formatfloat/long/int could have been
|
/* XXX To save some code duplication, formatfloat/long/int could have been
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue