]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #20538: UTF-7 incremental decoder produced inconsistant string when
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 8 Feb 2014 12:06:33 +0000 (14:06 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 8 Feb 2014 12:06:33 +0000 (14:06 +0200)
input was truncated in BASE64 section.

1  2 
Lib/test/test_codecs.py
Misc/NEWS
Objects/unicodeobject.c

Simple merge
diff --cc Misc/NEWS
index c0da6aa5517b6fcfbc13bfa269e384eabc272fd1,adce2c19b3d3d384061440deb706addea553564e..998d87c8f84383110cad3252087d9a8ea7e557c2
+++ b/Misc/NEWS
@@@ -10,16 -10,40 +10,19 @@@ Release date: 2014-02-0
  Core and Builtins
  -----------------
  
 -- Issue #17825: Cursor "^" is correctly positioned for SyntaxError and
 -  IndentationError.
 -
 -- Issue #2382: SyntaxError cursor "^" is now written at correct position in most
 -  cases when multibyte characters are in line (before "^").  This still not
 -  works correctly with wide East Asian characters.
 -
 -- Issue #18960: The first line of Python script could be executed twice when
 -  the source encoding was specified on the second line.  Now the source encoding
 -  declaration on the second line isn't effective if the first line contains
 -  anything except a comment.  'python -x' works now again with files with the
 -  source encoding declarations, and can be used to make Python batch files
 -  on Windows.
 -
 -- Issue #17432: Drop UCS2 from names of Unicode functions in python3.def.
 -
 -- Issue #19969: PyBytes_FromFormatV() now raises an OverflowError if "%c"
 -  argument is not in range [0; 255].
 -
 -- Issue #14432: Generator now clears the borrowed reference to the thread
 -  state. Fix a crash when a generator is created in a C thread that is
 -  destroyed while the generator is still used. The issue was that a generator
 -  contains a frame, and the frame kept a reference to the Python state of the
 -  destroyed C thread. The crash occurs when a trace function is setup.
 -
 -- Issue #19932: Fix typo in import.h, missing whitespaces in function prototypes.
+ - Issue #20538: UTF-7 incremental decoder produced inconsistant string when
+   input was truncated in BASE64 section.
 +- Issue #20404: io.TextIOWrapper (and hence the open() builtin) now uses the
 +  internal codec marking system added for issue #19619 to throw LookupError
 +  for known non-text encodings at stream construction time. The existing
 +  output type checks remain in place to deal with unmarked third party
 +  codecs.
  
 -- Issue #19729: In str.format(), fix recursive expansion in format spec.
 +- Issue #17162: Add PyType_GetSlot.
  
 -- Issue #19638: Fix possible crash / undefined behaviour from huge (more than 2
 -  billion characters) input strings in _Py_dg_strtod.
 +- Issue #20162: Fix an alignment issue in the siphash24() hash function which
 +  caused a crash on PowerPC 64-bit (ppc64).
  
  Library
  -------
index 02359e512a40788e00706a8ca38b175f0f96e21d,beafaa44963436da679d3d2d697350dfee577cc8..7a1aa161fbe468824873d3d3899cb7a96b78e925
@@@ -4459,8 -4474,16 +4459,16 @@@ utf7Error
      /* return state */
      if (consumed) {
          if (inShift) {
-             writer.pos = shiftOutStart; /* back off output */
              *consumed = startinpos;
 -            if (outpos != shiftOutStart &&
 -                PyUnicode_MAX_CHAR_VALUE(unicode) > 127) {
++            if (writer.pos != shiftOutStart && writer.maxchar > 127) {
+                 PyObject *result = PyUnicode_FromKindAndData(
 -                        PyUnicode_KIND(unicode), PyUnicode_DATA(unicode),
 -                        shiftOutStart);
 -                Py_DECREF(unicode);
 -                unicode = result;
++                        writer.kind, writer.data, shiftOutStart);
++                Py_XDECREF(errorHandler);
++                Py_XDECREF(exc);
++                _PyUnicodeWriter_Dealloc(&writer);
++                return result;
+             }
 -            outpos = shiftOutStart; /* back off output */
++            writer.pos = shiftOutStart; /* back off output */
          }
          else {
              *consumed = s-starts;