http://hg.python.org/peps/rev/a7b2b2d5b1d4
changeset: 5389:a7b2b2d5b1d4
user: Guido van Rossum <guido(a)dropbox.com>
date: Fri Feb 28 09:53:33 2014 -0800
summary:
PEP 257: Drop recommendation of extra blank line at end of docstring.
files:
pep-0257.txt | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/pep-0257.txt b/pep-0257.txt
--- a/pep-0257.txt
+++ b/pep-0257.txt
@@ -201,15 +201,14 @@
Keyword arguments:
real -- the real part (default 0.0)
imag -- the imaginary part (default 0.0)
-
"""
- if imag == 0.0 and real == 0.0: return complex_zero
+ if imag == 0.0 and real == 0.0:
+ return complex_zero
...
-The BDFL [3]_ recommends inserting a blank line between the last
-paragraph in a multi-line docstring and its closing quotes, placing
-the closing quotes on a line by themselves. This way, Emacs'
-``fill-paragraph`` command can be used on it.
+Unless the entire docstring fits on a line, place the closing quotes
+on a line by themselves. This way, Emacs' ``fill-paragraph`` command
+can be used on it.
Handling Docstring Indentation
--
Repository URL: http://hg.python.org/peps
http://hg.python.org/cpython/rev/2dd7b9618596
changeset: 89427:2dd7b9618596
user: Brett Cannon <brett(a)python.org>
date: Fri Feb 28 10:06:18 2014 -0500
summary:
Issue #20650: Tweak some awkward wording.
files:
Doc/library/asyncio-eventloop.rst | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -589,8 +589,8 @@
Arrange for a callback to be called in the specified executor.
- *executor* is a :class:`~concurrent.futures.Executor` instance,
- the default executor is used if *executor* is ``None``.
+ The *executor* argument should be an :class:`~concurrent.futures.Executor`
+ instance. The default executor is used if *executor* is ``None``.
This method is a :ref:`coroutine <coroutine>`.
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/c781843c4cbb
changeset: 89425:c781843c4cbb
parent: 89422:ec42ab5e0cb3
parent: 89424:8ebd0f382f9d
user: Martin v. Löwis <martin(a)v.loewis.de>
date: Fri Feb 28 15:47:15 2014 +0100
summary:
Merge heads
files:
.hgeol | 2 ++
Lib/test/coding20731.py | 4 ++++
Lib/test/test_source_encoding.py | 9 +++++++++
Misc/NEWS | 3 +++
Parser/tokenizer.c | 14 ++++++++++++--
5 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/.hgeol b/.hgeol
--- a/.hgeol
+++ b/.hgeol
@@ -38,6 +38,8 @@
Lib/venv/scripts/nt/* = BIN
+Lib/test/coding20731.py = BIN
+
# All other files (which presumably are human-editable) are "native".
# This must be the last rule!
diff --git a/Lib/test/coding20731.py b/Lib/test/coding20731.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/coding20731.py
@@ -0,0 +1,4 @@
+#coding:latin1
+
+
+
diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py
--- a/Lib/test/test_source_encoding.py
+++ b/Lib/test/test_source_encoding.py
@@ -5,6 +5,7 @@
import importlib
import os
import sys
+import subprocess
class SourceEncodingTest(unittest.TestCase):
@@ -58,6 +59,14 @@
# two bytes in common with the UTF-8 BOM
self.assertRaises(SyntaxError, eval, b'\xef\xbb\x20')
+ def test_20731(self):
+ sub = subprocess.Popen([sys.executable,
+ os.path.join(os.path.dirname(__file__),
+ 'coding20731.py')],
+ stderr=subprocess.PIPE)
+ err = sub.communicate()[1]
+ self.assertEquals(err, b'')
+
def test_error_message(self):
compile(b'# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
compile(b'\xef\xbb\xbf\n', 'dummy', 'exec')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -8,6 +8,9 @@
Core and Builtins
-----------------
+- Issue #20731: Properly position in source code files even if they
+ are opened in text mode. Patch by Serhiy Storchaka.
+
- Issue #20637: Key-sharing now also works for instance dictionaries of
subclasses. Patch by Peter Ingebretson.
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -498,9 +498,13 @@
fd = fileno(tok->fp);
/* Due to buffering the file offset for fd can be different from the file
- * position of tok->fp. */
+ * position of tok->fp. If tok->fp was opened in text mode on Windows,
+ * its file position counts CRLF as one char and can't be directly mapped
+ * to the file offset for fd. Instead we step back one byte and read to
+ * the end of line.*/
pos = ftell(tok->fp);
- if (pos == -1 || lseek(fd, (off_t)pos, SEEK_SET) == (off_t)-1) {
+ if (pos == -1 ||
+ lseek(fd, (off_t)(pos > 0 ? pos - 1 : pos), SEEK_SET) == (off_t)-1) {
PyErr_SetFromErrnoWithFilename(PyExc_OSError, NULL);
goto cleanup;
}
@@ -513,6 +517,12 @@
Py_XDECREF(tok->decoding_readline);
readline = _PyObject_GetAttrId(stream, &PyId_readline);
tok->decoding_readline = readline;
+ if (pos > 0) {
+ if (PyObject_CallObject(readline, NULL) == NULL) {
+ readline = NULL;
+ goto cleanup;
+ }
+ }
cleanup:
Py_XDECREF(stream);
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/8ebd0f382f9d
changeset: 89424:8ebd0f382f9d
parent: 89420:c8c9971bdc53
parent: 89423:ade5e4922a54
user: Martin v. Löwis <martin(a)v.loewis.de>
date: Fri Feb 28 15:43:36 2014 +0100
summary:
Merge with 3.3
files:
.hgeol | 2 ++
Lib/test/coding20731.py | 4 ++++
Lib/test/test_source_encoding.py | 9 +++++++++
Misc/NEWS | 3 +++
Parser/tokenizer.c | 14 ++++++++++++--
5 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/.hgeol b/.hgeol
--- a/.hgeol
+++ b/.hgeol
@@ -38,6 +38,8 @@
Lib/venv/scripts/nt/* = BIN
+Lib/test/coding20731.py = BIN
+
# All other files (which presumably are human-editable) are "native".
# This must be the last rule!
diff --git a/Lib/test/coding20731.py b/Lib/test/coding20731.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/coding20731.py
@@ -0,0 +1,4 @@
+#coding:latin1
+
+
+
diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py
--- a/Lib/test/test_source_encoding.py
+++ b/Lib/test/test_source_encoding.py
@@ -5,6 +5,7 @@
import importlib
import os
import sys
+import subprocess
class SourceEncodingTest(unittest.TestCase):
@@ -58,6 +59,14 @@
# two bytes in common with the UTF-8 BOM
self.assertRaises(SyntaxError, eval, b'\xef\xbb\x20')
+ def test_20731(self):
+ sub = subprocess.Popen([sys.executable,
+ os.path.join(os.path.dirname(__file__),
+ 'coding20731.py')],
+ stderr=subprocess.PIPE)
+ err = sub.communicate()[1]
+ self.assertEquals(err, b'')
+
def test_error_message(self):
compile(b'# -*- coding: iso-8859-15 -*-\n', 'dummy', 'exec')
compile(b'\xef\xbb\xbf\n', 'dummy', 'exec')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -8,6 +8,9 @@
Core and Builtins
-----------------
+- Issue #20731: Properly position in source code files even if they
+ are opened in text mode. Patch by Serhiy Storchaka.
+
- Issue #20637: Key-sharing now also works for instance dictionaries of
subclasses. Patch by Peter Ingebretson.
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -498,9 +498,13 @@
fd = fileno(tok->fp);
/* Due to buffering the file offset for fd can be different from the file
- * position of tok->fp. */
+ * position of tok->fp. If tok->fp was opened in text mode on Windows,
+ * its file position counts CRLF as one char and can't be directly mapped
+ * to the file offset for fd. Instead we step back one byte and read to
+ * the end of line.*/
pos = ftell(tok->fp);
- if (pos == -1 || lseek(fd, (off_t)pos, SEEK_SET) == (off_t)-1) {
+ if (pos == -1 ||
+ lseek(fd, (off_t)(pos > 0 ? pos - 1 : pos), SEEK_SET) == (off_t)-1) {
PyErr_SetFromErrnoWithFilename(PyExc_OSError, NULL);
goto cleanup;
}
@@ -513,6 +517,12 @@
Py_XDECREF(tok->decoding_readline);
readline = _PyObject_GetAttrId(stream, &PyId_readline);
tok->decoding_readline = readline;
+ if (pos > 0) {
+ if (PyObject_CallObject(readline, NULL) == NULL) {
+ readline = NULL;
+ goto cleanup;
+ }
+ }
cleanup:
Py_XDECREF(stream);
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/ade5e4922a54
changeset: 89423:ade5e4922a54
branch: 3.3
parent: 89419:daf44eb9c54e
user: Martin v. Löwis <martin(a)v.loewis.de>
date: Fri Feb 28 15:27:29 2014 +0100
summary:
Issue #20731: Properly position in source code files even if they
are opened in text mode. Patch by Serhiy Storchaka.
files:
.hgeol | 2 ++
Lib/test/coding20731.py | 4 ++++
Lib/test/test_coding.py | 9 ++++++++-
Misc/NEWS | 3 +++
Parser/tokenizer.c | 14 ++++++++++++--
5 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/.hgeol b/.hgeol
--- a/.hgeol
+++ b/.hgeol
@@ -37,6 +37,8 @@
Lib/venv/scripts/nt/* = BIN
+Lib/test/coding20731.py = BIN
+
# All other files (which presumably are human-editable) are "native".
# This must be the last rule!
diff --git a/Lib/test/coding20731.py b/Lib/test/coding20731.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/coding20731.py
@@ -0,0 +1,4 @@
+#coding:latin1
+
+
+
diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py
--- a/Lib/test/test_coding.py
+++ b/Lib/test/test_coding.py
@@ -1,6 +1,6 @@
import unittest
from test.support import TESTFN, unlink, unload
-import importlib, os, sys
+import importlib, os, sys, subprocess
class CodingTest(unittest.TestCase):
def test_bad_coding(self):
@@ -58,6 +58,13 @@
self.assertTrue(c.exception.args[0].startswith(expected),
msg=c.exception.args[0])
+ def test_20731(self):
+ sub = subprocess.Popen([sys.executable,
+ os.path.join(os.path.dirname(__file__),
+ 'coding20731.py')],
+ stderr=subprocess.PIPE)
+ err = sub.communicate()[1]
+ self.assertEquals(err, b'')
if __name__ == "__main__":
unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #20731: Properly position in source code files even if they
+ are opened in text mode. Patch by Serhiy Storchaka.
+
- Issue #19619: str.encode, bytes.decode and bytearray.decode now use an
internal API to throw LookupError for known non-text encodings, rather
than attempting the encoding or decoding operation and then throwing a
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -498,9 +498,13 @@
fd = fileno(tok->fp);
/* Due to buffering the file offset for fd can be different from the file
- * position of tok->fp. */
+ * position of tok->fp. If tok->fp was opened in text mode on Windows,
+ * its file position counts CRLF as one char and can't be directly mapped
+ * to the file offset for fd. Instead we step back one byte and read to
+ * the end of line.*/
pos = ftell(tok->fp);
- if (pos == -1 || lseek(fd, (off_t)pos, SEEK_SET) == (off_t)-1) {
+ if (pos == -1 ||
+ lseek(fd, (off_t)(pos > 0 ? pos - 1 : pos), SEEK_SET) == (off_t)-1) {
PyErr_SetFromErrnoWithFilename(PyExc_OSError, NULL);
goto cleanup;
}
@@ -513,6 +517,12 @@
Py_XDECREF(tok->decoding_readline);
readline = _PyObject_GetAttrId(stream, &PyId_readline);
tok->decoding_readline = readline;
+ if (pos > 0) {
+ if (PyObject_CallObject(readline, NULL) == NULL) {
+ readline = NULL;
+ goto cleanup;
+ }
+ }
cleanup:
Py_XDECREF(stream);
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/82ec02db7fe6
changeset: 89421:82ec02db7fe6
user: Nick Coghlan <ncoghlan(a)gmail.com>
date: Fri Feb 28 23:35:05 2014 +1000
summary:
Close #20757: return success for skipped pip uninstall
The 3.4rc2 Windows uninstaller would fail if pip had been updated
to a version that didn't match the version installed by ensurepip.
This skip is no longer treated as an error, so an updated pip ends
up being handled like any other pip installed package and is left
alone by the CPython uninstaller.
files:
Lib/ensurepip/__init__.py | 5 +++--
Lib/test/test_ensurepip.py | 6 ++++--
Misc/NEWS | 7 +++++++
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -128,9 +128,10 @@
# If the pip version doesn't match the bundled one, leave it alone
if pip.__version__ != _PIP_VERSION:
- msg = ("ensurepip will only uninstall a matching pip "
+ msg = ("ensurepip will only uninstall a matching version "
"({!r} installed, {!r} bundled)")
- raise RuntimeError(msg.format(pip.__version__, _PIP_VERSION))
+ print(msg.format(pip.__version__, _PIP_VERSION), file=sys.stderr)
+ return
_require_ssl_for_pip()
_disable_pip_configuration_settings()
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -196,10 +196,12 @@
ensurepip._uninstall_helper()
self.run_pip.assert_not_called()
- def test_uninstall_fails_with_wrong_version(self):
+ def test_uninstall_skipped_with_warning_for_wrong_version(self):
with fake_pip("not a valid version"):
- with self.assertRaises(RuntimeError):
+ with test.support.captured_stderr() as stderr:
ensurepip._uninstall_helper()
+ warning = stderr.getvalue().strip()
+ self.assertIn("only uninstall a matching version", warning)
self.run_pip.assert_not_called()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,13 @@
- Issue #20743: Fix a reference leak in test_tcl.
+Build
+-----
+
+- Issue #20757: The ensurepip helper for the Windows uninstaller now skips
+ uninstalling pip (rather than failing) if the user has updated pip to a
+ different version from the one bundled with ensurepip.
+
Tools/Demos
-----------
--
Repository URL: http://hg.python.org/cpython