summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-02-16 01:08:01 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-02-16 01:08:01 (GMT)
commit15231548d20b2a6fcac2830935ec076bed42448f (patch)
tree6831a1db2fb258a04b63c7089b086dd3f9f40c20 /Objects
parentc7f6cf62473d48b2c814b135b0026e74c3dfc3c5 (diff)
downloadcpython-15231548d20b2a6fcac2830935ec076bed42448f.zip
cpython-15231548d20b2a6fcac2830935ec076bed42448f.tar.gz
cpython-15231548d20b2a6fcac2830935ec076bed42448f.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index e09a1a8..1652b2f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6601,17 +6601,21 @@ strtounicode(Py_UNICODE *buffer, const char *charbuffer)
static int
doubletounicode(Py_UNICODE *buffer, size_t len, const char *format, double x)
{
+ Py_ssize_t result;
+
PyOS_ascii_formatd((char *)buffer, len, format, x);
- return Py_SAFE_DOWNCAST(strtounicode(buffer, (char *)buffer),
- Py_ssize_t, int);
+ result = strtounicode(buffer, (char *)buffer);
+ return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
}
static int
longtounicode(Py_UNICODE *buffer, size_t len, const char *format, long x)
{
+ Py_ssize_t result;
+
PyOS_snprintf((char *)buffer, len, format, x);
- return Py_SAFE_DOWNCAST(strtounicode(buffer, (char *)buffer),
- Py_ssize_t, int);
+ result = strtounicode(buffer, (char *)buffer);
+ return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
}
/* XXX To save some code duplication, formatfloat/long/int could have been