diff --git a/Demo/comparisons/sortingtest.py b/Demo/comparisons/sortingtest.py
index cabf6260d9c..08a73e3754d 100755
--- a/Demo/comparisons/sortingtest.py
+++ b/Demo/comparisons/sortingtest.py
@@ -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
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py
index ab2c5454899..8607531b24e 100644
--- a/Doc/tools/sphinxext/pyspecific.py
+++ b/Doc/tools/sphinxext/pyspecific.py
@@ -20,6 +20,20 @@
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('%s' % text)
+
# Support for marking up and linking to bugs.python.org issues
diff --git a/Doc/tools/sphinxext/static/basic.css b/Doc/tools/sphinxext/static/basic.css
index caf52e152d1..aeb13816d1f 100644
--- a/Doc/tools/sphinxext/static/basic.css
+++ b/Doc/tools/sphinxext/static/basic.css
@@ -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 @@ .versionmodified {
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 @@ .impl-detail {
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;
}
diff --git a/Lib/Cookie.py b/Lib/Cookie.py
index b2f7427aa94..99a94da2789 100644
--- a/Lib/Cookie.py
+++ b/Lib/Cookie.py
@@ -624,7 +624,9 @@ def load(self, rawdata):
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()
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 02946788f3e..ea279911b6c 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -109,7 +109,7 @@ def get(self, block=True, timeout=None):
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):
diff --git a/Lib/pdb.py b/Lib/pdb.py
index e9f5632b14f..3e5e8984c13 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -198,7 +198,9 @@ def displayhook(self, obj):
"""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:]
diff --git a/Lib/platform.py b/Lib/platform.py
index ee187490974..90ad93de2bb 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -10,7 +10,7 @@
"""
# This module is maintained by Marc-Andre Lemburg .
# 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.
#
diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py
index 05c10130088..b887dc0d5ef 100644
--- a/Lib/test/test_kqueue.py
+++ b/Lib/test/test_kqueue.py
@@ -162,6 +162,22 @@ def test_queue_event(self):
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)
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 0708f8163ef..1c067d776c0 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -34,6 +34,9 @@ def get_exception_format(self, func, exc):
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 @@ def test_caret(self):
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?)
diff --git a/Lib/threading.py b/Lib/threading.py
index c1791d7aef5..1182f192269 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -133,7 +133,7 @@ def acquire(self, blocking=1):
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 @@ def _is_owned(self):
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 @@ def wait(self, timeout=None):
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:
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 3d877ee1502..ed0f256c77e 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -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
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 6cf89425274..5cc065308f6 100644
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -625,7 +625,9 @@ def open(self, url, new=0, autoraise=1):
# 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
diff --git a/Misc/gdbinit b/Misc/gdbinit
index e648f1647bc..316ff3d525c 100644
--- a/Misc/gdbinit
+++ b/Misc/gdbinit
@@ -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))
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 7e144f2df1e..c62cec5a3d1 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -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;
}
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 2638bdc7b6d..a254233323d 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -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);
diff --git a/Python/peephole.c b/Python/peephole.c
index e9da377dc68..139a62b858c 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -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