]> granicus.if.org Git - python/commitdiff
Merged revisions 73206,73232,73299,73683,74020,74185,74544,74643,74647,74817,74838...
authorGeorg Brandl <georg@python.org>
Tue, 27 Oct 2009 15:39:53 +0000 (15:39 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 27 Oct 2009 15:39:53 +0000 (15:39 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73206 | georg.brandl | 2009-06-04 11:15:12 +0200 (Do, 04 Jun 2009) | 1 line

  #3584: ignore trailing newlines when placing the caret for a SyntaxError location.
........
  r73232 | georg.brandl | 2009-06-04 20:59:58 +0200 (Do, 04 Jun 2009) | 1 line

  Add test for #3684.
........
  r73299 | georg.brandl | 2009-06-08 20:41:36 +0200 (Mo, 08 Jun 2009) | 1 line

  Typo fix.
........
  r73683 | georg.brandl | 2009-06-29 16:44:49 +0200 (Mo, 29 Jun 2009) | 1 line

  Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint.
........
  r74020 | georg.brandl | 2009-07-16 09:18:07 +0200 (Do, 16 Jul 2009) | 1 line

  #5910: fix kqueue for calls with more than one event.
........
  r74185 | georg.brandl | 2009-07-23 11:17:09 +0200 (Do, 23 Jul 2009) | 1 line

  Fix the "pylocals" gdb command.
........
  r74544 | georg.brandl | 2009-08-24 19:12:30 +0200 (Mo, 24 Aug 2009) | 1 line

  #6775: fix python.org URLs in README.
........
  r74643 | georg.brandl | 2009-09-04 08:59:20 +0200 (Fr, 04 Sep 2009) | 2 lines

  Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module.
........
  r74647 | georg.brandl | 2009-09-04 10:17:04 +0200 (Fr, 04 Sep 2009) | 2 lines

  Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented.
........
  r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line

  Make deprecation notices as visible as warnings are right now.
........
  r74838 | georg.brandl | 2009-09-16 18:22:12 +0200 (Mi, 16 Sep 2009) | 1 line

  Remove some more boilerplate from the actual tests in test_pdb.
........
  r74839 | georg.brandl | 2009-09-16 18:36:39 +0200 (Mi, 16 Sep 2009) | 1 line

  Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
........
  r74865 | georg.brandl | 2009-09-17 09:49:37 +0200 (Do, 17 Sep 2009) | 1 line

  #6912: add "with" block support to pindent.
........
  r74946 | georg.brandl | 2009-09-19 10:43:16 +0200 (Sa, 19 Sep 2009) | 1 line

  Update bug tracker reference.
........
  r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line

  #7125: fix typo.
........
  r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line

  Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
  r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line

  Fix stylesheet for multi-paragraph impl-details.
........
  r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line

  Fix a demo.
........

18 files changed:
Demo/comparisons/sortingtest.py
Doc/tools/sphinxext/pyspecific.py
Doc/tools/sphinxext/static/basic.css
Lib/Cookie.py
Lib/multiprocessing/queues.py
Lib/pdb.py
Lib/platform.py
Lib/test/test_kqueue.py
Lib/test/test_traceback.py
Lib/threading.py
Lib/traceback.py
Lib/webbrowser.py
Misc/gdbinit
Modules/_ctypes/_ctypes.c
Modules/selectmodule.c
Python/peephole.c
README
Tools/scripts/pindent.py

index cabf6260d9c3bef0adb7565171f1fd4472859742..08a73e3754d987fe5f5013bd1db8a867797cddbb 100755 (executable)
@@ -24,7 +24,6 @@
 # - Handles blank input lines correctly
 
 import re
-import string
 import sys
 
 def main():
@@ -32,18 +31,13 @@ def main():
     def makekey(item, prog=prog):
         match = prog.match(item)
         if match:
-            var, num = match.group(1, 2)
-            return string.atoi(num), var
+            var, num = match.groups()
+            return int(num), var
         else:
             # Bad input -- pretend it's a var with value 0
             return 0, item
-    while 1:
-        line = sys.stdin.readline()
-        if not line:
-            break
-        items = line.split()
-        items = map(makekey, items)
-        items.sort()
+    for line in sys.stdin:
+        items = sorted(makekey(item) for item in line.split())
         for num, var in items:
             print "%s=%s" % (var, num),
         print
index ab2c5454899eb0d73f908557eceaf8740b1e67a2..8607531b24e2c09d6d565d57399434727a742dcb 100644 (file)
@@ -20,6 +20,20 @@ Body.enum.converters['loweralpha'] = \
     Body.enum.converters['lowerroman'] = \
     Body.enum.converters['upperroman'] = lambda x: None
 
+# monkey-patch HTML translator to give versionmodified paragraphs a class
+from sphinx.writers.html import HTMLTranslator
+from sphinx.locale import versionlabels
+HTMLTranslator.visit_versionmodified = new_visit_versionmodified
+
+def new_visit_versionmodified(self, node):
+    self.body.append(self.starttag(node, 'p', CLASS=node['type']))
+    text = versionlabels[node['type']] % node['version']
+    if len(node):
+        text += ': '
+    else:
+        text += '.'
+    self.body.append('<span class="versionmodified">%s</span>' % text)
+
 
 # Support for marking up and linking to bugs.python.org issues
 
index caf52e152d1b1d5e6034c58084ca1fd74eab90ac..aeb13816d1fb5f2ad7e39cdbc594656bc5029a34 100644 (file)
@@ -5,15 +5,6 @@
 
 /* -- main layout ----------------------------------------------------------- */
 
-div.documentwrapper {
-    float: left;
-    width: 100%;
-}
-
-div.bodywrapper {
-    margin: 0 0 0 230px;
-}
-
 div.clearer {
     clear: both;
 }
@@ -338,6 +329,12 @@ dl.glossary dt {
     font-style: italic;
 }
 
+p.deprecated {
+    background-color: #ffe4e4;
+    border: 1px solid #f66;
+    padding: 7px
+}
+
 .system-message {
     background-color: #fda;
     padding: 5px;
@@ -355,8 +352,12 @@ dl.glossary dt {
     border: 1px solid #ccc;
 }
 
-.impl-detail p {
-    margin: 0;
+.impl-detail .compound-first {
+    margin-top: 0;
+}
+
+.impl-detail .compound-last {
+    margin-bottom: 0;
 }
 
 /* -- code displays --------------------------------------------------------- */
@@ -405,7 +406,7 @@ img.math {
     vertical-align: middle;
 }
 
-div.math p {
+div.body div.math p {
     text-align: center;
 }
 
index b2f7427aa94f734ab2a34285917fb11eb0b2c4fc..99a94da2789c4fc69a0b55094552a498bd2f8150 100644 (file)
@@ -624,7 +624,9 @@ class BaseCookie(dict):
         if type(rawdata) == type(""):
             self.__ParseString(rawdata)
         else:
-            self.update(rawdata)
+            # self.update() wouldn't call our custom __setitem__
+            for k, v in rawdata.items():
+                self[k] = v
         return
     # end load()
 
index 02946788f3ee86a4469c44b44502647282f83d11..ea279911b6c12fd6ae0d4c8f815da2707ecb2b37 100644 (file)
@@ -109,7 +109,7 @@ class Queue(object):
                 self._rlock.release()
 
     def qsize(self):
-        # Raises NotImplementError on Mac OSX because of broken sem_getvalue()
+        # Raises NotImplementedError on Mac OSX because of broken sem_getvalue()
         return self._maxsize - self._sem._semlock._get_value()
 
     def empty(self):
index e9f5632b14f777c383833eaf9f88aec7446f874f..3e5e8984c13b2432f7ae2e3a1873cb8fb30ad439 100755 (executable)
@@ -198,7 +198,9 @@ class Pdb(bdb.Bdb, cmd.Cmd):
         """Custom displayhook for the exec in default(), which prevents
         assignment of the _ variable in the builtins.
         """
-        print repr(obj)
+        # reproduce the behavior of the standard displayhook, not printing None
+        if obj is not None:
+            print repr(obj)
 
     def default(self, line):
         if line[:1] == '!': line = line[1:]
index ee187490974923ac4d4002fb0893326f61d81b25..90ad93de2bbd33936ec243b8533e38782d5483bb 100755 (executable)
@@ -10,7 +10,7 @@
 """
 #    This module is maintained by Marc-Andre Lemburg <mal@egenix.com>.
 #    If you find problems, please submit bug reports/patches via the
-#    Python SourceForge Project Page and assign them to "lemburg".
+#    Python bug tracker (http://bugs.python.org) and assign them to "lemburg".
 #
 #    Note: Please keep this module compatible to Python 1.5.2.
 #
index 05c1013008897aabc46d4b2da286c971b977ad10..b887dc0d5ef4de86ee4b04272f17ee10f1635ef8 100644 (file)
@@ -162,6 +162,22 @@ class TestKQueue(unittest.TestCase):
         server.close()
         serverSocket.close()
 
+    def testPair(self):
+        kq = select.kqueue()
+        a, b = socket.socketpair()
+
+        a.send(b'foo')
+        event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
+        event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
+        r = kq.control([event1, event2], 1, 1)
+        self.assertTrue(r)
+        self.assertFalse(r[0].flags & select.KQ_EV_ERROR)
+        self.assertEquals(b.recv(r[0].data), b'foo')
+
+        a.close()
+        b.close()
+        kq.close()
+
 def test_main():
     test_support.run_unittest(TestKQueue)
 
index 0708f8163ef23e312c18c813c64f8ae1348a9e10..1c067d776c05fbb1d6a97078d1b73856cb4c6f75 100644 (file)
@@ -34,6 +34,9 @@ class TracebackCases(unittest.TestCase):
     def syntax_error_with_caret(self):
         compile("def fact(x):\n\treturn x!\n", "?", "exec")
 
+    def syntax_error_with_caret_2(self):
+        compile("1 +\n", "?", "exec")
+
     def syntax_error_without_caret(self):
         # XXX why doesn't compile raise the same traceback?
         import test.badsyntax_nocaret
@@ -49,6 +52,12 @@ class TracebackCases(unittest.TestCase):
         self.assert_("^" in err[2]) # third line has caret
         self.assert_(err[1].find("!") == err[2].find("^")) # in the right place
 
+        err = self.get_exception_format(self.syntax_error_with_caret_2,
+                                        SyntaxError)
+        self.assert_("^" in err[2]) # third line has caret
+        self.assert_(err[2].count('\n') == 1) # and no additional newline
+        self.assert_(err[1].find("+") == err[2].find("^")) # in the right place
+
     def test_nocaret(self):
         if is_jython:
             # jython adds a caret in this case (why shouldn't it?)
index c1791d7aef5ec2b243a321609a599d966d499d88..1182f1922690572c7a988512b270de3c0caa873b 100644 (file)
@@ -133,7 +133,7 @@ class _RLock(_Verbose):
 
     def release(self):
         if self.__owner is not current_thread():
-            raise RuntimeError("cannot release un-aquired lock")
+            raise RuntimeError("cannot release un-acquired lock")
         self.__count = count = self.__count - 1
         if not count:
             self.__owner = None
@@ -227,7 +227,7 @@ class _Condition(_Verbose):
 
     def wait(self, timeout=None):
         if not self._is_owned():
-            raise RuntimeError("cannot wait on un-aquired lock")
+            raise RuntimeError("cannot wait on un-acquired lock")
         waiter = _allocate_lock()
         waiter.acquire()
         self.__waiters.append(waiter)
@@ -269,7 +269,7 @@ class _Condition(_Verbose):
 
     def notify(self, n=1):
         if not self._is_owned():
-            raise RuntimeError("cannot notify on un-aquired lock")
+            raise RuntimeError("cannot notify on un-acquired lock")
         __waiters = self.__waiters
         waiters = __waiters[:n]
         if not waiters:
index 3d877ee1502b38281c76d30c373993602e40f62f..ed0f256c77eea559e5a0133b5ae07386818cebd8 100644 (file)
@@ -190,7 +190,7 @@ def format_exception_only(etype, value):
         if badline is not None:
             lines.append('    %s\n' % badline.strip())
             if offset is not None:
-                caretspace = badline[:offset].lstrip()
+                caretspace = badline.rstrip('\n')[:offset].lstrip()
                 # non-space whitespace (likes tabs) must be kept for alignment
                 caretspace = ((c.isspace() and c or ' ') for c in caretspace)
                 # only three spaces to account for offset1 == pos 0
index 6cf8942527418fd177eec246e59a81f79d9fffb0..5cc065308f6e7fe4f7cd1a270b2ea715a1b32a02 100644 (file)
@@ -625,7 +625,9 @@ if "BROWSER" in os.environ:
     # and prepend to _tryorder
     for cmdline in _userchoices:
         if cmdline != '':
-            _synthesize(cmdline, -1)
+            cmd = _synthesize(cmdline, -1)
+            if cmd[1] is None:
+                register(cmdline, None, GenericBrowser(cmdline), -1)
     cmdline = None # to make del work if _userchoices was empty
     del cmdline
     del _userchoices
index e648f1647bc266c1856a327fdddea01ede156cce..316ff3d525cdd111857613c2c8ffcb4fbcb70f8a 100644 (file)
@@ -29,7 +29,7 @@ end
 # print the local variables of the current frame
 define pylocals
     set $_i = 0
-    while $_i < f->f_nlocals
+    while $_i < f->f_code->co_nlocals
        if f->f_localsplus + $_i != 0
            set $_names = co->co_varnames
            set $_name = PyString_AsString(PyTuple_GetItem($_names, $_i))
index 7e144f2df1e0f98641433d0b31e12396e04561e2..c62cec5a3d18f2411c95eed2b6eb75c8e1030989 100644 (file)
@@ -1889,17 +1889,16 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
        }
        fmt = getentry(PyString_AS_STRING(proto));
        if (fmt == NULL) {
-               Py_DECREF(result);
                PyErr_Format(PyExc_ValueError,
                             "_type_ '%s' not supported",
                             PyString_AS_STRING(proto));
-               return NULL;
+               goto error;
        }
 
        stgdict = (StgDictObject *)PyObject_CallObject(
                (PyObject *)&StgDict_Type, NULL);
        if (!stgdict)
-               return NULL;
+               goto error;
 
        stgdict->ffi_type_pointer = *fmt->pffi_type;
        stgdict->align = fmt->pffi_type->alignment;
@@ -1914,6 +1913,7 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 #endif
        if (stgdict->format == NULL) {
                Py_DECREF(result);
+               Py_DECREF(proto);
                Py_DECREF((PyObject *)stgdict);
                return NULL;
        }
index 2638bdc7b6dd805f6857bbbc6fbde99acc72ab4d..a254233323d1ad346b2969ed493f3a17a5e4b136 100644 (file)
@@ -1487,7 +1487,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
        if (nevents < 0) {
                PyErr_Format(PyExc_ValueError,
                        "Length of eventlist must be 0 or positive, got %d",
-                       nchanges);
+                       nevents);
                return NULL;
        }
 
@@ -1545,6 +1545,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
                        PyErr_NoMemory();
                        return NULL;
                }
+               i = 0;
                while ((ei = PyIter_Next(it)) != NULL) {
                        if (!kqueue_event_Check(ei)) {
                                Py_DECREF(ei);
@@ -1553,7 +1554,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
                                        "select.kevent objects");
                                goto error;
                        } else {
-                               chl[i] = ((kqueue_event_Object *)ei)->e;
+                               chl[i++] = ((kqueue_event_Object *)ei)->e;
                        }
                        Py_DECREF(ei);
                }
@@ -1584,7 +1585,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
                goto error;
        }
 
-       for (i=0; i < gotevents; i++) {
+       for (i = 0; i < gotevents; i++) {
                kqueue_event_Object *ch;
 
                ch = PyObject_New(kqueue_event_Object, &kqueue_event_Type);
index e9da377dc68f9a4a562793f048d044a1c9699aa9..139a62b858cd3a3d3bd89692c80bbe3bbad2f8f7 100644 (file)
@@ -297,7 +297,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
 
        /* Bail out if an exception is set */
        if (PyErr_Occurred())
-               goto exitUnchanged;
+               goto exitError;
 
        /* Bypass optimization when the lineno table is too complex */
        assert(PyString_Check(lineno_obj));
@@ -315,7 +315,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
        /* Make a modifiable copy of the code string */
        codestr = (unsigned char *)PyMem_Malloc(codelen);
        if (codestr == NULL)
-               goto exitUnchanged;
+               goto exitError;
        codestr = (unsigned char *)memcpy(codestr, 
                                          PyString_AS_STRING(code), codelen);
 
@@ -330,11 +330,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
        /* Mapping to new jump targets after NOPs are removed */
        addrmap = (int *)PyMem_Malloc(codelen * sizeof(int));
        if (addrmap == NULL)
-               goto exitUnchanged;
+               goto exitError;
 
        blocks = markblocks(codestr, codelen);
        if (blocks == NULL)
-               goto exitUnchanged;
+               goto exitError;
        assert(PyList_Check(consts));
 
        for (i=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
@@ -391,7 +391,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
                                }
                                if (j == PyList_GET_SIZE(consts)) {
                                        if (PyList_Append(consts, Py_None) == -1)
-                                               goto exitUnchanged;                                        
+                                               goto exitError;
                                }
                                assert(PyList_GET_ITEM(consts, j) == Py_None);
                                codestr[i] = LOAD_CONST;
@@ -618,6 +618,9 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
        PyMem_Free(blocks);
        return code;
 
+ exitError:
+       code = NULL;
+
  exitUnchanged:
        if (blocks != NULL)
                PyMem_Free(blocks);
@@ -625,6 +628,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
                PyMem_Free(addrmap);
        if (codestr != NULL)
                PyMem_Free(codestr);
-       Py_INCREF(code);
+       Py_XINCREF(code);
        return code;
 }
diff --git a/README b/README
index fc4c1cf83025e1526f7f0351758a6481c1c1302a..ce2bc05c11b3fa10544ab40c9667ec78a2d165cc 100644 (file)
--- a/README
+++ b/README
@@ -107,26 +107,26 @@ Newsgroups and Mailing Lists
 Read comp.lang.python, a high-volume discussion newsgroup about
 Python, or comp.lang.python.announce, a low-volume moderated newsgroup
 for Python-related announcements.  These are also accessible as
-mailing lists: see http://www.python.org/community/lists.html for an
+mailing lists: see http://www.python.org/community/lists/ for an
 overview of these and many other Python-related mailing lists.
 
 Archives are accessible via the Google Groups Usenet archive; see
 http://groups.google.com/.  The mailing lists are also archived, see
-http://www.python.org/community/lists.html for details.
+http://www.python.org/community/lists/ for details.
 
 
 Bug reports
 -----------
 
 To report or search for bugs, please use the Python Bug
-Tracker at http://bugs.python.org.
+Tracker at http://bugs.python.org/.
 
 
 Patches and contributions
 -------------------------
 
 To submit a patch or other contribution, please use the Python Patch
-Manager at http://bugs.python.org.  Guidelines
+Manager at http://bugs.python.org/.  Guidelines
 for patch submission may be found at http://www.python.org/dev/patches/.
 
 If you have a proposal to change Python, you may want to send an email to the
@@ -188,7 +188,7 @@ Troubleshooting
 See also the platform specific notes in the next section.
 
 If you run into other trouble, see the FAQ
-(http://www.python.org/doc/faq) for hints on what can go wrong, and
+(http://www.python.org/doc/faq/) for hints on what can go wrong, and
 how to fix it.
 
 If you rerun the configure script with different options, remove all
@@ -404,7 +404,7 @@ HP-UX:  When using threading, you may have to add -D_REENTRANT to the
 HP-UX ia64: When building on the ia64 (Itanium) platform using HP's
         compiler, some experience has shown that the compiler's
         optimiser produces a completely broken version of python
-        (see http://www.python.org/sf/814976). To work around this,
+        (see http://bugs.python.org/814976). To work around this,
         edit the Makefile and remove -O from the OPT line.
 
         To build a 64-bit executable on an Itanium 2 system using HP's
@@ -424,7 +424,7 @@ HP-UX ia64: When building on the ia64 (Itanium) platform using HP's
         if it remains set.)  You still have to edit the Makefile and
         remove -O from the OPT line.
 
-HP PA-RISC 2.0: A recent bug report (http://www.python.org/sf/546117)
+HP PA-RISC 2.0: A recent bug report (http://bugs.python.org/546117)
         suggests that the C compiler in this 64-bit system has bugs
         in the optimizer that break Python.  Compiling without
         optimization solves the problems.
@@ -1171,9 +1171,9 @@ Misc/python-mode.el.  Originally written by the famous Tim Peters, it
 is now maintained by the equally famous Barry Warsaw (it's no
 coincidence that they now both work on the same team).  The latest
 version, along with various other contributed Python-related Emacs
-goodies, is online at http://www.python.org/emacs/python-mode.  And
+goodies, is online at http://www.python.org/emacs/python-mode/.  And
 if you are planning to edit the Python C code, please pick up the
-latest version of CC Mode http://www.python.org/emacs/cc-mode; it
+latest version of CC Mode http://www.python.org/emacs/cc-mode/; it
 contains a "python" style used throughout most of the Python C source
 files.  (Newer versions of Emacs or XEmacs may already come with the
 latest version of python-mode.)
index ec440d14fb346afc7569daee0e5998ab8be06369..7bfc4153d2eaa17472c57c74dbc310c07e2fe529 100755 (executable)
@@ -88,10 +88,10 @@ next = {}
 next['if'] = next['elif'] = 'elif', 'else', 'end'
 next['while'] = next['for'] = 'else', 'end'
 next['try'] = 'except', 'finally'
-next['except'] = 'except', 'else', 'end'
+next['except'] = 'except', 'else', 'finally', 'end'
 next['else'] = next['finally'] = next['def'] = next['class'] = 'end'
 next['end'] = ()
-start = 'if', 'while', 'for', 'try', 'def', 'class'
+start = 'if', 'while', 'for', 'try', 'with', 'def', 'class'
 
 class PythonIndenter: