diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-12-27 17:05:29 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-12-27 17:05:29 (GMT) |
commit | 828a7066f12e758c30829363c8ec9018c6c2a94f (patch) | |
tree | 96fb5d0d088d0313a4f31a7a7da84c69cfa34474 /Objects | |
parent | ba48608711a5139006227c0a4c800ce352b2b77b (diff) | |
download | cpython-828a7066f12e758c30829363c8ec9018c6c2a94f.zip cpython-828a7066f12e758c30829363c8ec9018c6c2a94f.tar.gz cpython-828a7066f12e758c30829363c8ec9018c6c2a94f.tar.bz2 |
Merged revisions 67898,67904-67907,67912,67918,67920-67921,67923-67924,67927,67930,67932,67943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67898 | benjamin.peterson | 2008-12-21 15:00:53 -0600 (Sun, 21 Dec 2008) | 1 line
compute DISTVERSION with patchlevel.py
........
r67904 | benjamin.peterson | 2008-12-22 14:44:58 -0600 (Mon, 22 Dec 2008) | 1 line
less attitude
........
r67905 | benjamin.peterson | 2008-12-22 14:51:15 -0600 (Mon, 22 Dec 2008) | 1 line
fix #4720: the format to PyArg_ParseTupleAndKeywords can now start with '|'
........
r67906 | benjamin.peterson | 2008-12-22 14:52:53 -0600 (Mon, 22 Dec 2008) | 1 line
add NEWS note
........
r67907 | benjamin.peterson | 2008-12-22 16:12:19 -0600 (Mon, 22 Dec 2008) | 1 line
silence compiler warning
........
r67912 | georg.brandl | 2008-12-23 06:37:21 -0600 (Tue, 23 Dec 2008) | 2 lines
Fix missing "svn" command.
........
r67918 | georg.brandl | 2008-12-23 09:44:25 -0600 (Tue, 23 Dec 2008) | 2 lines
Markup fix.
........
r67920 | benjamin.peterson | 2008-12-23 14:09:28 -0600 (Tue, 23 Dec 2008) | 1 line
use a global variable, so the compiler doesn't optimize the assignment out
........
r67921 | benjamin.peterson | 2008-12-23 14:12:33 -0600 (Tue, 23 Dec 2008) | 1 line
make global static
........
r67923 | benjamin.peterson | 2008-12-24 09:10:27 -0600 (Wed, 24 Dec 2008) | 1 line
#4736 BufferRWPair.closed shouldn't try to call another property as a function
........
r67924 | benjamin.peterson | 2008-12-24 10:10:05 -0600 (Wed, 24 Dec 2008) | 1 line
pretend exceptions don't exist a while longer
........
r67927 | benjamin.peterson | 2008-12-26 17:26:30 -0600 (Fri, 26 Dec 2008) | 1 line
python version is included in file name now
........
r67930 | hirokazu.yamamoto | 2008-12-26 22:19:48 -0600 (Fri, 26 Dec 2008) | 2 lines
Issue #4740: Use HIGHEST_PROTOCOL in pickle test.
(There is no behavior difference in 2.x because HIGHEST_PROTOCOL == 2)
........
r67932 | alexandre.vassalotti | 2008-12-27 00:36:10 -0600 (Sat, 27 Dec 2008) | 5 lines
Remove unnecessary casts related to unicode_decode_call_errorhandler.
Make the _PyUnicode_Resize macro a static function.
These changes are needed to avoid breaking strict aliasing rules.
........
r67943 | alexandre.vassalotti | 2008-12-27 04:02:59 -0600 (Sat, 27 Dec 2008) | 2 lines
Fix bogus unicode tests in pickletester.
........
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ba14843..9615d43 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -386,7 +386,8 @@ void unicode_dealloc(register PyUnicodeObject *unicode) } } -int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) +static +int _PyUnicode_Resize(PyUnicodeObject **unicode, Py_ssize_t length) { register PyUnicodeObject *v; @@ -395,7 +396,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) PyErr_BadInternalCall(); return -1; } - v = (PyUnicodeObject *)*unicode; + v = *unicode; if (v == NULL || !PyUnicode_Check(v) || Py_REFCNT(v) != 1 || length < 0) { PyErr_BadInternalCall(); return -1; @@ -412,7 +413,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) Py_UNICODE_COPY(w->str, v->str, length < v->length ? length : v->length); Py_DECREF(*unicode); - *unicode = (PyObject *)w; + *unicode = w; return 0; } @@ -421,9 +422,10 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) return unicode_resize(v, length); } -/* Internal API for use in unicodeobject.c only ! */ -#define _PyUnicode_Resize(unicodevar, length) \ - PyUnicode_Resize(((PyObject **)(unicodevar)), length) +int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length) +{ + return _PyUnicode_Resize((PyUnicodeObject **)unicode, length); +} PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size) @@ -937,7 +939,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs) PyObject_Free(callresults); if (abuffer) PyObject_Free(abuffer); - _PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string)); + PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string)); return string; fail: if (callresults) { @@ -1345,7 +1347,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler const char *encoding, const char *reason, const char *input, Py_ssize_t insize, Py_ssize_t *startinpos, Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr, - PyObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr) + PyUnicodeObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr) { static char *argparse = "O!n;decoding error handler must return (unicode, int) tuple"; @@ -1405,7 +1407,7 @@ int unicode_decode_call_errorhandler(const char *errors, PyObject **errorHandler if (requiredsize > outsize) { if (requiredsize<2*outsize) requiredsize = 2*outsize; - if (PyUnicode_Resize(output, requiredsize) < 0) + if (_PyUnicode_Resize(output, requiredsize) < 0) goto onError; *outptr = PyUnicode_AS_UNICODE(*output) + *outpos; } @@ -1604,7 +1606,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, errors, &errorHandler, "utf7", errmsg, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) + &unicode, &outpos, &p)) goto onError; } @@ -1615,7 +1617,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, errors, &errorHandler, "utf7", "unterminated shift sequence", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) + &unicode, &outpos, &p)) goto onError; if (s < e) goto restart; @@ -1942,7 +1944,7 @@ PyObject *PyUnicode_DecodeUTF8Stateful(const char *s, errors, &errorHandler, "utf8", errmsg, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) + &unicode, &outpos, &p)) goto onError; } if (consumed) @@ -2222,7 +2224,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s, errors, &errorHandler, "utf32", errmsg, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&unicode, &outpos, &p)) + &unicode, &outpos, &p)) goto onError; } @@ -2496,7 +2498,7 @@ PyUnicode_DecodeUTF16Stateful(const char *s, errors, &errorHandler, "utf16", errmsg, starts, size, &startinpos, &endinpos, &exc, (const char **)&q, - (PyObject **)&unicode, &outpos, &p)) + &unicode, &outpos, &p)) goto onError; } @@ -2717,7 +2719,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, errors, &errorHandler, "unicodeescape", "end of string in escape sequence", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; goto nextByte; } @@ -2729,7 +2731,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, errors, &errorHandler, "unicodeescape", message, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; goto nextByte; } @@ -2768,7 +2770,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, errors, &errorHandler, "unicodeescape", "illegal Unicode character", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; } break; @@ -2810,7 +2812,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, errors, &errorHandler, "unicodeescape", message, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; break; @@ -2824,7 +2826,7 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, errors, &errorHandler, "unicodeescape", message, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; } else { @@ -3113,7 +3115,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s, errors, &errorHandler, "rawunicodeescape", "truncated \\uXXXX", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; goto nextByte; } @@ -3145,7 +3147,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s, errors, &errorHandler, "rawunicodeescape", "\\Uxxxxxxxx out of range", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; } nextByte: @@ -3315,7 +3317,7 @@ PyObject *_PyUnicode_DecodeUnicodeInternal(const char *s, errors, &errorHandler, "unicode_internal", reason, starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) { + &v, &outpos, &p)) { goto onError; } } @@ -3695,7 +3697,7 @@ PyObject *PyUnicode_DecodeASCII(const char *s, errors, &errorHandler, "ascii", "ordinal not in range(128)", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) + &v, &outpos, &p)) goto onError; } } @@ -3996,7 +3998,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s, errors, &errorHandler, "charmap", "character maps to <undefined>", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) { + &v, &outpos, &p)) { goto onError; } continue; @@ -4046,7 +4048,7 @@ PyObject *PyUnicode_DecodeCharmap(const char *s, errors, &errorHandler, "charmap", "character maps to <undefined>", starts, size, &startinpos, &endinpos, &exc, &s, - (PyObject **)&v, &outpos, &p)) { + &v, &outpos, &p)) { Py_DECREF(x); goto onError; } @@ -4797,7 +4799,7 @@ int charmaptranslate_makespace(PyObject **outobj, Py_UNICODE **outp, /* exponentially overallocate to minimize reallocations */ if (requiredsize < 2 * oldsize) requiredsize = 2 * oldsize; - if (_PyUnicode_Resize(outobj, requiredsize) < 0) + if (PyUnicode_Resize(outobj, requiredsize) < 0) return -1; *outp = PyUnicode_AS_UNICODE(*outobj) + outpos; } @@ -4976,7 +4978,7 @@ PyObject *PyUnicode_TranslateCharmap(const Py_UNICODE *p, /* Resize if we allocated to much */ respos = str-PyUnicode_AS_UNICODE(res); if (respos<PyUnicode_GET_SIZE(res)) { - if (_PyUnicode_Resize(&res, respos) < 0) + if (PyUnicode_Resize(&res, respos) < 0) goto onError; } Py_XDECREF(exc); |