diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-20 23:38:09 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-20 23:38:09 (GMT) |
commit | 5d14c2b8f87b23a9257c97b5f98dd097ca289c78 (patch) | |
tree | e7f70d363ad656494d995fce4e74e95ba70ca688 /Objects | |
parent | 81e8ab5ba074694750072fb50081b77da16180a0 (diff) | |
download | cpython-5d14c2b8f87b23a9257c97b5f98dd097ca289c78.zip cpython-5d14c2b8f87b23a9257c97b5f98dd097ca289c78.tar.gz cpython-5d14c2b8f87b23a9257c97b5f98dd097ca289c78.tar.bz2 |
Merged revisions 59056-59076 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59064 | christian.heimes | 2007-11-20 02:48:48 +0100 (Tue, 20 Nov 2007) | 1 line
Fixed bug #1470
........
r59066 | martin.v.loewis | 2007-11-20 03:46:02 +0100 (Tue, 20 Nov 2007) | 2 lines
Patch #1468: Package Lib/test/*.pem.
........
r59068 | christian.heimes | 2007-11-20 04:21:02 +0100 (Tue, 20 Nov 2007) | 1 line
Another fix for test_shutil. Martin pointed out that it breaks some build bots
........
r59073 | nick.coghlan | 2007-11-20 15:55:57 +0100 (Tue, 20 Nov 2007) | 1 line
Backport some main.c cleanup from the py3k branch
........
r59076 | amaury.forgeotdarc | 2007-11-21 00:31:27 +0100 (Wed, 21 Nov 2007) | 6 lines
The incremental decoder for utf-7 must preserve its state between calls.
Solves issue1460.
Might not be a backport candidate: a new API function was added,
and some code may rely on details in utf-7.py.
........
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 426dc07..65c2980 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1519,6 +1519,14 @@ PyObject *PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors) { + return PyUnicode_DecodeUTF7Stateful(s, size, errors, NULL); +} + +PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, + Py_ssize_t size, + const char *errors, + Py_ssize_t *consumed) +{ const char *starts = s; Py_ssize_t startinpos; Py_ssize_t endinpos; @@ -1537,8 +1545,11 @@ PyObject *PyUnicode_DecodeUTF7(const char *s, unicode = _PyUnicode_New(size); if (!unicode) return NULL; - if (size == 0) + if (size == 0) { + if (consumed) + *consumed = 0; return (PyObject *)unicode; + } p = unicode->str; e = s + size; @@ -1624,7 +1635,7 @@ PyObject *PyUnicode_DecodeUTF7(const char *s, goto onError; } - if (inShift) { + if (inShift && !consumed) { outpos = p-PyUnicode_AS_UNICODE(unicode); endinpos = size; if (unicode_decode_call_errorhandler( @@ -1636,6 +1647,12 @@ PyObject *PyUnicode_DecodeUTF7(const char *s, if (s < e) goto restart; } + if (consumed) { + if(inShift) + *consumed = startinpos; + else + *consumed = s-starts; + } if (_PyUnicode_Resize(&unicode, p - PyUnicode_AS_UNICODE(unicode)) < 0) goto onError; |