[Python-checkins] r81148 - in python/branches/py3k-jit: Doc/library/http.client.rst Doc/library/xml.dom.rst Lib/test/test_asyncore.py Lib/test/test_capi.py Lib/test/test_math.py Lib/test/test_urlparse.py Lib/test/test_zlib.py Lib/urllib/parse.py Misc/NEWS Modules/_ssl.c Modules/_testcapimodule.c Modules/zlibmodule.c Python/dtoa.c Python/errors.c

jeffrey.yasskin python-checkins at python.org
Thu May 13 23:29:30 CEST 2010


Author: jeffrey.yasskin
Date: Thu May 13 23:29:30 2010
New Revision: 81148

Log:
Merged revisions 81096,81100,81103,81107,81109,81116,81127,81132,81134,81136,81138,81142 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81096 | antoine.pitrou | 2010-05-11 16:36:40 -0700 (Tue, 11 May 2010) | 11 lines
  
  Merged revisions 81094 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81094 | antoine.pitrou | 2010-05-12 01:32:31 +0200 (mer., 12 mai 2010) | 6 lines
    
    Issue #8672: Add a zlib test ensuring that an incomplete stream can be
    handled by a decompressor object without errors (it returns incomplete
    uncompressed data).
  ........
................
  r81100 | antoine.pitrou | 2010-05-11 16:46:02 -0700 (Tue, 11 May 2010) | 10 lines
  
  Merged revisions 81098 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81098 | antoine.pitrou | 2010-05-12 01:42:28 +0200 (mer., 12 mai 2010) | 5 lines
    
    Issue #8681: Make the zlib module's error messages more informative when
    the zlib itself doesn't give any detailed explanation.
  ........
................
  r81103 | giampaolo.rodola | 2010-05-11 17:33:15 -0700 (Tue, 11 May 2010) | 9 lines
  
  Merged revisions 81102 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81102 | giampaolo.rodola | 2010-05-12 02:29:27 +0200 (mer, 12 mag 2010) | 1 line
    
    Removed the assertion that dispatcher.connected attribute must be False after a single connect() call. Solaris and FreeBSD buildbots failures showed how connect() can succeed even in a single call. All bo failures should definitively be fixed now.
  ........
................
  r81107 | fred.drake | 2010-05-11 18:36:11 -0700 (Tue, 11 May 2010) | 13 lines
  
  Merged revisions 81087,81106 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81087 | fred.drake | 2010-05-11 14:12:27 -0400 (Tue, 11 May 2010) | 2 lines
    
    fix typo
  ........
    r81106 | fred.drake | 2010-05-11 21:22:03 -0400 (Tue, 11 May 2010) | 2 lines
    
    fix error introduced in previous commit, and the adjacent additional typo
  ........
................
  r81109 | fred.drake | 2010-05-11 19:34:50 -0700 (Tue, 11 May 2010) | 11 lines
  
  Merged revisions 81108 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81108 | fred.drake | 2010-05-11 22:24:50 -0400 (Tue, 11 May 2010) | 4 lines
    
    - clarify Attr.name comment on the presence of colons in namespace mode
    - document Attr.value
    - wrap some long lines
  ........
................
  r81116 | antoine.pitrou | 2010-05-12 07:05:24 -0700 (Wed, 12 May 2010) | 9 lines
  
  Merged revisions 81115 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81115 | antoine.pitrou | 2010-05-12 16:02:34 +0200 (mer., 12 mai 2010) | 3 lines
    
    Improve _ssl.c formatting
  ........
................
  r81127 | mark.dickinson | 2010-05-12 12:54:51 -0700 (Wed, 12 May 2010) | 9 lines
  
  Merged revisions 81126 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81126 | mark.dickinson | 2010-05-12 20:53:36 +0100 (Wed, 12 May 2010) | 1 line
    
    Fix unused variable in test_factorial.
  ........
................
  r81132 | senthil.kumaran | 2010-05-12 20:37:23 -0700 (Wed, 12 May 2010) | 9 lines
  
  Merged revisions 81130 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81130 | senthil.kumaran | 2010-05-13 08:55:21 +0530 (Thu, 13 May 2010) | 3 lines
    
    Fix Issue8657 - adding git and git+ssh as know schemes.
  ........
................
  r81134 | mark.dickinson | 2010-05-13 04:52:22 -0700 (Thu, 13 May 2010) | 1 line
  
  Remove unnecessary assignments.
................
  r81136 | victor.stinner | 2010-05-13 09:20:26 -0700 (Thu, 13 May 2010) | 12 lines
  
  Blocked revisions 81135 via svnmerge (r81135 is a merge of r80163 from py3k)
  
  ........
    r81135 | victor.stinner | 2010-05-13 18:18:14 +0200 (jeu., 13 mai 2010) | 6 lines
  
    Issue #8422, test_genericpath: skip the creation of a directory with an invalid
    UTF name on Mac OS X because the OS deny it (the name have to be a valid UTF8
    string).
  
    Merge r80163 from py3k branch.
  ........
................
  r81138 | victor.stinner | 2010-05-13 09:23:09 -0700 (Thu, 13 May 2010) | 10 lines
  
  Blocked revisions 81137 via svnmerge
  
  ........
    r81137 | victor.stinner | 2010-05-13 18:22:15 +0200 (jeu., 13 mai 2010) | 4 lines
    
    Fix verb tense in skip message.
    
    Ooops, merge also r80334 (patch by r.david.murray)
  ........
................
  r81142 | jeffrey.yasskin | 2010-05-13 11:31:05 -0700 (Thu, 13 May 2010) | 6 lines
  
  Make PyErr_Occurred return NULL if there is no current thread.  Previously it
  would Py_FatalError, which called PyErr_Occurred, resulting in a semi-infinite
  recursion.
  
  Fixes issue 3605.
................


Modified:
   python/branches/py3k-jit/   (props changed)
   python/branches/py3k-jit/Doc/library/http.client.rst
   python/branches/py3k-jit/Doc/library/xml.dom.rst
   python/branches/py3k-jit/Lib/test/test_asyncore.py
   python/branches/py3k-jit/Lib/test/test_capi.py
   python/branches/py3k-jit/Lib/test/test_math.py
   python/branches/py3k-jit/Lib/test/test_urlparse.py
   python/branches/py3k-jit/Lib/test/test_zlib.py
   python/branches/py3k-jit/Lib/urllib/parse.py
   python/branches/py3k-jit/Misc/NEWS
   python/branches/py3k-jit/Modules/_ssl.c
   python/branches/py3k-jit/Modules/_testcapimodule.c
   python/branches/py3k-jit/Modules/zlibmodule.c
   python/branches/py3k-jit/Python/dtoa.c
   python/branches/py3k-jit/Python/errors.c

Modified: python/branches/py3k-jit/Doc/library/http.client.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/http.client.rst	(original)
+++ python/branches/py3k-jit/Doc/library/http.client.rst	Thu May 13 23:29:30 2010
@@ -521,9 +521,8 @@
    >>> data2 = r2.read()
    >>> conn.close()
 
-Here is an example session that uses ``HEAD`` method. Note that ``HEAD`` method
-never returns any data. ::
-
+Here is an example session that uses the ``HEAD`` method.  Note that the
+``HEAD`` method never returns any data. ::
 
    >>> import http.client
    >>> conn = http.client.HTTPConnection("www.python.org")

Modified: python/branches/py3k-jit/Doc/library/xml.dom.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/xml.dom.rst	(original)
+++ python/branches/py3k-jit/Doc/library/xml.dom.rst	Thu May 13 23:29:30 2010
@@ -693,18 +693,27 @@
 
 .. attribute:: Attr.name
 
-   The attribute name.  In a namespace-using document it may have colons in it.
+   The attribute name.
+   In a namespace-using document it may include a colon.
 
 
 .. attribute:: Attr.localName
 
-   The part of the name following the colon if there is one, else the entire name.
+   The part of the name following the colon if there is one, else the
+   entire name.
    This is a read-only attribute.
 
 
 .. attribute:: Attr.prefix
 
-   The part of the name preceding the colon if there is one, else the empty string.
+   The part of the name preceding the colon if there is one, else the
+   empty string.
+
+
+.. attribute:: Attr.value
+
+   The text value of the attribute.  This is a synonym for the
+   :attr:`nodeValue` attribute.
 
 
 .. _dom-attributelist-objects:

Modified: python/branches/py3k-jit/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_asyncore.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_asyncore.py	Thu May 13 23:29:30 2010
@@ -619,12 +619,8 @@
         # we start disconnected
         self.assertFalse(server.connected)
         self.assertTrue(server.accepting)
-        # XXX - Solaris seems to connect() immediately even without
-        # starting the poller. This is something which should be
-        # fixed as handle_connect() gets called immediately even if
-        # no connection actually took place (see issue #8490).
-        if not sys.platform.startswith("sunos"):
-            self.assertFalse(client.connected)
+        # this can't be taken for granted across all platforms
+        #self.assertFalse(client.connected)
         self.assertFalse(client.accepting)
 
         # execute some loops so that client connects to server

Modified: python/branches/py3k-jit/Lib/test/test_capi.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_capi.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_capi.py	Thu May 13 23:29:30 2010
@@ -2,9 +2,10 @@
 # these are all functions _testcapi exports whose name begins with 'test_'.
 
 from __future__ import with_statement
+import random
+import subprocess
 import sys
 import time
-import random
 import unittest
 from test import support
 try:
@@ -35,6 +36,19 @@
         self.assertEqual(testfunction.attribute, "test")
         self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test")
 
+    def test_no_FatalError_infinite_loop(self):
+        p = subprocess.Popen([sys.executable, "-c",
+                              'import _testcapi;'
+                              '_testcapi.crash_no_current_thread()'],
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+        (out, err) = p.communicate()
+        self.assertEqual(out, b'')
+        # This used to cause an infinite loop.
+        self.assertEqual(err,
+                         b'Fatal Python error:'
+                         b' PyThreadState_Get: no current thread\n')
+
 
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class TestPendingCalls(unittest.TestCase):

Modified: python/branches/py3k-jit/Lib/test/test_math.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_math.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_math.py	Thu May 13 23:29:30 2010
@@ -372,7 +372,7 @@
             return result
         values = list(range(10)) + [50, 100, 500]
         random.shuffle(values)
-        for x in range(10):
+        for x in values:
             for cast in (int, float):
                 self.assertEqual(math.factorial(cast(x)), fact(x), (x, fact(x), math.factorial(x)))
         self.assertRaises(ValueError, math.factorial, -1)

Modified: python/branches/py3k-jit/Lib/test/test_urlparse.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_urlparse.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_urlparse.py	Thu May 13 23:29:30 2010
@@ -104,7 +104,12 @@
              ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
               '', '', ''),
              ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
-              '', ''))
+              '', '')),
+            ('git+ssh://git@github.com/user/project.git',
+            ('git+ssh', 'git at github.com','/user/project.git',
+             '','',''),
+            ('git+ssh', 'git at github.com','/user/project.git',
+             '', ''))
             ]
         for url, parsed, split in testcases:
             self.checkRoundtrips(url, parsed, split)

Modified: python/branches/py3k-jit/Lib/test/test_zlib.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_zlib.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_zlib.py	Thu May 13 23:29:30 2010
@@ -140,6 +140,13 @@
         for ob in x, bytearray(x):
             self.assertEqual(zlib.decompress(ob), data)
 
+    def test_incomplete_stream(self):
+        # An useful error message is given
+        x = zlib.compress(HAMLET_SCENE)
+        self.assertRaisesRegexp(zlib.error,
+            "Error -5 while decompressing data: incomplete or truncated stream",
+            zlib.decompress, x[:-1])
+
     # Memory use of the following functions takes into account overallocation
 
     @precisionbigmemtest(size=_1G + 1024 * 1024, memuse=3)
@@ -379,6 +386,19 @@
         dco = zlib.decompressobj()
         self.assertEqual(dco.flush(), b"") # Returns nothing
 
+    def test_decompress_incomplete_stream(self):
+        # This is 'foo', deflated
+        x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
+        # For the record
+        self.assertEqual(zlib.decompress(x), b'foo')
+        self.assertRaises(zlib.error, zlib.decompress, x[:-5])
+        # Omitting the stream end works with decompressor objects
+        # (see issue #8672).
+        dco = zlib.decompressobj()
+        y = dco.decompress(x[:-5])
+        y += dco.flush()
+        self.assertEqual(y, b'foo')
+
     if hasattr(zlib.compressobj(), "copy"):
         def test_compresscopy(self):
             # Test copying a compression object

Modified: python/branches/py3k-jit/Lib/urllib/parse.py
==============================================================================
--- python/branches/py3k-jit/Lib/urllib/parse.py	(original)
+++ python/branches/py3k-jit/Lib/urllib/parse.py	Thu May 13 23:29:30 2010
@@ -41,7 +41,7 @@
 uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
                'imap', 'wais', 'file', 'mms', 'https', 'shttp',
                'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
-               'svn', 'svn+ssh', 'sftp','nfs']
+               'svn', 'svn+ssh', 'sftp', 'nfs',' git', 'git+ssh']
 non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',
                     'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
 uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',

Modified: python/branches/py3k-jit/Misc/NEWS
==============================================================================
--- python/branches/py3k-jit/Misc/NEWS	(original)
+++ python/branches/py3k-jit/Misc/NEWS	Thu May 13 23:29:30 2010
@@ -351,6 +351,9 @@
 Library
 -------
 
+- Issue #8681: Make the zlib module's error messages more informative when
+  the zlib itself doesn't give any detailed explanation.
+
 - The audioop module now supports sound fragments of length greater
   than 2**31 bytes on 64-bit machines, and is PY_SSIZE_T_CLEAN.
 
@@ -1276,6 +1279,10 @@
 Tests
 -----
 
+- Issue #8672: Add a zlib test ensuring that an incomplete stream can be
+  handled by a decompressor object without errors (it returns incomplete
+  uncompressed data).
+
 - Issue #8533: regrtest uses backslashreplace error handler for stdout to avoid
   UnicodeEncodeError (write non-ASCII character to stdout using ASCII encoding)
 

Modified: python/branches/py3k-jit/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ssl.c	(original)
+++ python/branches/py3k-jit/Modules/_ssl.c	Thu May 13 23:29:30 2010
@@ -182,8 +182,7 @@
             break;
         case SSL_ERROR_WANT_X509_LOOKUP:
             p = PY_SSL_ERROR_WANT_X509_LOOKUP;
-            errstr =
-                "The operation did not complete (X509 lookup)";
+            errstr = "The operation did not complete (X509 lookup)";
             break;
         case SSL_ERROR_WANT_CONNECT:
             p = PY_SSL_ERROR_WANT_CONNECT;
@@ -196,15 +195,14 @@
                 PySocketSockObject *s
                   = (PySocketSockObject *) PyWeakref_GetObject(obj->Socket);
                 if (ret == 0 || (((PyObject *)s) == Py_None)) {
-                  p = PY_SSL_ERROR_EOF;
-                  errstr =
-                      "EOF occurred in violation of protocol";
+                    p = PY_SSL_ERROR_EOF;
+                    errstr = "EOF occurred in violation of protocol";
                 } else if (ret == -1) {
-                  /* underlying BIO reported an I/O error */
-                  return s->errorhandler();
+                    /* underlying BIO reported an I/O error */
+                    return s->errorhandler();
                 } else { /* possible? */
-                  p = PY_SSL_ERROR_SYSCALL;
-                  errstr = "Some I/O error occurred";
+                    p = PY_SSL_ERROR_SYSCALL;
+                    errstr = "Some I/O error occurred";
                 }
             } else {
                 p = PY_SSL_ERROR_SYSCALL;
@@ -221,8 +219,7 @@
                 /* XXX Protected by global interpreter lock */
                 errstr = ERR_error_string(e, NULL);
             else {              /* possible? */
-                errstr =
-                    "A failure in the SSL library occurred";
+                errstr = "A failure in the SSL library occurred";
             }
             break;
         }
@@ -325,7 +322,7 @@
     if (certreq != PY_SSL_CERT_NONE) {
         if (cacerts_file == NULL) {
             errstr = ERRSTR("No root certificates specified for "
-                      "verification of other-side certificates.");
+                            "verification of other-side certificates.");
             goto fail;
         } else {
             PySSL_BEGIN_ALLOW_THREADS
@@ -490,15 +487,15 @@
         }
         if (sockstate == SOCKET_HAS_TIMED_OUT) {
             PyErr_SetString(PySSLErrorObject,
-                ERRSTR("The handshake operation timed out"));
+                            ERRSTR("The handshake operation timed out"));
             return NULL;
         } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
             PyErr_SetString(PySSLErrorObject,
-                ERRSTR("Underlying socket has been closed."));
+                            ERRSTR("Underlying socket has been closed."));
             return NULL;
         } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
             PyErr_SetString(PySSLErrorObject,
-              ERRSTR("Underlying socket too large for select()."));
+                            ERRSTR("Underlying socket too large for select()."));
             return NULL;
         } else if (sockstate == SOCKET_IS_NONBLOCKING) {
             break;
@@ -544,7 +541,7 @@
         goto fail;
     }
     value_obj = PyUnicode_DecodeUTF8((char *) valuebuf,
-                                             buflen, "strict");
+                                     buflen, "strict");
     OPENSSL_free(valuebuf);
     if (value_obj == NULL) {
         Py_DECREF(name_obj);
@@ -1217,11 +1214,9 @@
             goto error;
         }
         if (err == SSL_ERROR_WANT_READ) {
-            sockstate =
-                check_socket_and_wait_for_timeout(sock, 0);
+            sockstate = check_socket_and_wait_for_timeout(sock, 0);
         } else if (err == SSL_ERROR_WANT_WRITE) {
-            sockstate =
-                check_socket_and_wait_for_timeout(sock, 1);
+            sockstate = check_socket_and_wait_for_timeout(sock, 1);
         } else {
             sockstate = SOCKET_OPERATION_OK;
         }
@@ -1334,7 +1329,7 @@
             goto error;
         } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
             PyErr_SetString(PySSLErrorObject,
-                "Underlying socket too large for select().");
+                            "Underlying socket too large for select().");
             goto error;
         } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
             count = 0;
@@ -1350,11 +1345,9 @@
         if (PyErr_CheckSignals())
             goto error;
         if (err == SSL_ERROR_WANT_READ) {
-            sockstate =
-              check_socket_and_wait_for_timeout(sock, 0);
+            sockstate = check_socket_and_wait_for_timeout(sock, 0);
         } else if (err == SSL_ERROR_WANT_WRITE) {
-            sockstate =
-              check_socket_and_wait_for_timeout(sock, 1);
+            sockstate = check_socket_and_wait_for_timeout(sock, 1);
         } else if ((err == SSL_ERROR_ZERO_RETURN) &&
                    (SSL_get_shutdown(self->ssl) ==
                     SSL_RECEIVED_SHUTDOWN))
@@ -1547,7 +1540,7 @@
     double entropy;
 
     if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
-    return NULL;
+        return NULL;
     RAND_add(buf, len, entropy);
     Py_INCREF(Py_None);
     return Py_None;
@@ -1578,15 +1571,15 @@
     int bytes;
 
     if (!PyUnicode_Check(arg))
-    return PyErr_Format(PyExc_TypeError,
-                        "RAND_egd() expected string, found %s",
-                        Py_TYPE(arg)->tp_name);
+        return PyErr_Format(PyExc_TypeError,
+                            "RAND_egd() expected string, found %s",
+                            Py_TYPE(arg)->tp_name);
     bytes = RAND_egd(_PyUnicode_AsString(arg));
     if (bytes == -1) {
-    PyErr_SetString(PySSLErrorObject,
-                    "EGD connection failed or EGD did not return "
-                    "enough data to seed the PRNG");
-    return NULL;
+        PyErr_SetString(PySSLErrorObject,
+                        "EGD connection failed or EGD did not return "
+                        "enough data to seed the PRNG");
+        return NULL;
     }
     return PyLong_FromLong(bytes);
 }

Modified: python/branches/py3k-jit/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k-jit/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k-jit/Modules/_testcapimodule.c	Thu May 13 23:29:30 2010
@@ -1597,6 +1597,17 @@
     return PyErr_NewExceptionWithDoc(name, doc, base, dict);
 }
 
+/* Test that the fatal error from not having a current thread doesn't
+   cause an infinite loop.  Run via Lib/test/test_capi.py */
+static PyObject *
+crash_no_current_thread(PyObject *self)
+{
+    Py_BEGIN_ALLOW_THREADS
+    PyErr_SetString(PyExc_SystemError, "bork bork bork");
+    Py_END_ALLOW_THREADS
+    return NULL;
+}
+
 static PyMethodDef TestMethods[] = {
     {"raise_exception",         raise_exception,                 METH_VARARGS},
     {"raise_memoryerror",   (PyCFunction)raise_memoryerror,  METH_NOARGS},
@@ -1650,6 +1661,7 @@
     {"code_newempty", code_newempty,                     METH_VARARGS},
     {"make_exception_with_doc", (PyCFunction)make_exception_with_doc,
      METH_VARARGS | METH_KEYWORDS},
+    {"crash_no_current_thread", (PyCFunction)crash_no_current_thread, METH_NOARGS},
     {NULL, NULL} /* sentinel */
 };
 

Modified: python/branches/py3k-jit/Modules/zlibmodule.c
==============================================================================
--- python/branches/py3k-jit/Modules/zlibmodule.c	(original)
+++ python/branches/py3k-jit/Modules/zlibmodule.c	Thu May 13 23:29:30 2010
@@ -52,10 +52,24 @@
 static void
 zlib_error(z_stream zst, int err, char *msg)
 {
-    if (zst.msg == Z_NULL)
+    const char *zmsg = zst.msg;
+    if (zmsg == Z_NULL) {
+        switch (err) {
+        case Z_BUF_ERROR:
+            zmsg = "incomplete or truncated stream";
+            break;
+        case Z_STREAM_ERROR:
+            zmsg = "inconsistent stream state";
+            break;
+        case Z_DATA_ERROR:
+            zmsg = "invalid input data";
+            break;
+        }
+    }
+    if (zmsg == Z_NULL)
         PyErr_Format(ZlibError, "Error %d %s", err, msg);
     else
-        PyErr_Format(ZlibError, "Error %d %s: %.200s", err, msg, zst.msg);
+        PyErr_Format(ZlibError, "Error %d %s: %.200s", err, msg, zmsg);
 }
 
 PyDoc_STRVAR(compressobj__doc__,
@@ -241,8 +255,7 @@
              * process the inflate call() due to an error in the data.
              */
             if (zst.avail_out > 0) {
-                PyErr_Format(ZlibError, "Error %i while decompressing data",
-                             err);
+                zlib_error(zst, err, "while decompressing data");
                 inflateEnd(&zst);
                 goto error;
             }

Modified: python/branches/py3k-jit/Python/dtoa.c
==============================================================================
--- python/branches/py3k-jit/Python/dtoa.c	(original)
+++ python/branches/py3k-jit/Python/dtoa.c	Thu May 13 23:29:30 2010
@@ -1382,7 +1382,6 @@
     Bigint *b, *d;
     int b2, d2, dd, i, nd, nd0, odd, p2, p5;
 
-    dd = 0; /* silence compiler warning about possibly unused variable */
     nd = bc->nd;
     nd0 = bc->nd0;
     p5 = nd + bc->e0;
@@ -2362,7 +2361,7 @@
 
     /* set pointers to NULL, to silence gcc compiler warnings and make
        cleanup easier on error */
-    mlo = mhi = b = S = 0;
+    mlo = mhi = S = 0;
     s0 = 0;
 
     u.d = dd;
@@ -2713,8 +2712,6 @@
      * and for all and pass them and a shift to quorem, so it
      * can do shifts and ors to compute the numerator for q.
      */
-    if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f))
-        i = 32 - i;
 #define iInc 28
     i = dshift(S, s2);
     b2 += i;

Modified: python/branches/py3k-jit/Python/errors.c
==============================================================================
--- python/branches/py3k-jit/Python/errors.c	(original)
+++ python/branches/py3k-jit/Python/errors.c	Thu May 13 23:29:30 2010
@@ -130,9 +130,14 @@
 PyObject *
 PyErr_Occurred(void)
 {
-    PyThreadState *tstate = PyThreadState_GET();
+    /* If there is no thread state, PyThreadState_GET calls
+       Py_FatalError, which calls PyErr_Occurred.  To avoid the
+       resulting infinite loop, we inline PyThreadState_GET here and
+       treat no thread as no error. */
+    PyThreadState *tstate =
+        ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current));
 
-    return tstate->curexc_type;
+    return tstate == NULL ? NULL : tstate->curexc_type;
 }
 
 


More information about the Python-checkins mailing list