From solipsis at pitrou.net Thu Nov 1 05:07:52 2018
From: solipsis at pitrou.net (solipsis at pitrou.net)
Date: Thu, 01 Nov 2018 09:07:52 +0000
Subject: [Python-checkins] Daily reference leaks (4243df51fe43): sum=7
Message-ID: <20181101090752.1.6761465670776A94@psf.io>
results for 4243df51fe43 on branch "default"
--------------------------------------------
test_collections leaked [-7, 1, 7] memory blocks, sum=1
test_functools leaked [0, 3, 1] memory blocks, sum=4
test_multiprocessing_fork leaked [-2, 2, 0] memory blocks, sum=0
test_multiprocessing_forkserver leaked [2, 0, 0] memory blocks, sum=2
test_multiprocessing_spawn leaked [-1, -1, 2] memory blocks, sum=0
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogdDGf3b', '--timeout', '7200']
From webhook-mailer at python.org Thu Nov 1 06:33:48 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Thu, 01 Nov 2018 10:33:48 -0000
Subject: [Python-checkins] bpo-35128: Fix spacing issues in warning.warn()
messages. (GH-10268)
Message-ID:
https://github.com/python/cpython/commit/4b5e62dbb22a3593e0db266c12f805b727a42b00
commit: 4b5e62dbb22a3593e0db266c12f805b727a42b00
branch: master
author: Pablo Aguiar
committer: Serhiy Storchaka
date: 2018-11-01T12:33:35+02:00
summary:
bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268)
files:
M Lib/bz2.py
M Lib/ftplib.py
M Lib/imaplib.py
M Lib/poplib.py
M Lib/smtplib.py
diff --git a/Lib/bz2.py b/Lib/bz2.py
index 3ab099147190..21e8ff49c67b 100644
--- a/Lib/bz2.py
+++ b/Lib/bz2.py
@@ -66,7 +66,7 @@ def __init__(self, filename, mode="r", buffering=_sentinel, compresslevel=9):
self._mode = _MODE_CLOSED
if buffering is not _sentinel:
- warnings.warn("Use of 'buffering' argument is deprecated and ignored"
+ warnings.warn("Use of 'buffering' argument is deprecated and ignored "
"since Python 3.0.",
DeprecationWarning,
stacklevel=2)
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 05840d492360..9611282ecacb 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -732,7 +732,7 @@ def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index e451413acf5a..dd237f7704ac 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -1277,7 +1277,7 @@ def __init__(self, host='', port=IMAP4_SSL_PORT, keyfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom ssl_context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/poplib.py b/Lib/poplib.py
index d8a62c034327..9796f0d2f9c5 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -436,7 +436,7 @@ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index acfc3586e1c0..3c5ac75ab8ab 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -764,7 +764,7 @@ def starttls(self, keyfile=None, certfile=None, context=None):
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
if context is None:
context = ssl._create_stdlib_context(certfile=certfile,
@@ -1021,7 +1021,7 @@ def __init__(self, host='', port=0, local_hostname=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
From webhook-mailer at python.org Thu Nov 1 06:48:56 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 10:48:56 -0000
Subject: [Python-checkins] bpo-33578: Add getstate/setstate for CJK codec
(GH-6984)
Message-ID:
https://github.com/python/cpython/commit/ac22f6aa989f18c33c12615af1c66c73cf75d5e7
commit: ac22f6aa989f18c33c12615af1c66c73cf75d5e7
branch: master
author: Christopher Thorne
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-11-01T03:48:49-07:00
summary:
bpo-33578: Add getstate/setstate for CJK codec (GH-6984)
This implements getstate and setstate for the cjkcodecs multibyte incremental encoders/decoders, primarily to fix issues with seek/tell.
The encoder getstate/setstate is slightly tricky as the "state" is pending bytes + MultibyteCodec_State but only an integer can be returned. The approach I've taken is to encode this data into a long, similar to how .tell() encodes a "cookie_type" as a long.
https://bugs.python.org/issue33578
files:
A Misc/NEWS.d/next/Library/2018-06-08-23-55-34.bpo-33578.7oSsjG.rst
M Lib/test/test_io.py
M Lib/test/test_multibytecodec.py
M Misc/ACKS
M Modules/cjkcodecs/_codecs_cn.c
M Modules/cjkcodecs/clinic/multibytecodec.c.h
M Modules/cjkcodecs/multibytecodec.c
M Modules/cjkcodecs/multibytecodec.h
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index d927bb96ceb5..14352ff84fff 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -2971,6 +2971,34 @@ def test_seek_and_tell_with_data(data, min_pos=0):
finally:
StatefulIncrementalDecoder.codecEnabled = 0
+ def test_multibyte_seek_and_tell(self):
+ f = self.open(support.TESTFN, "w", encoding="euc_jp")
+ f.write("AB\n\u3046\u3048\n")
+ f.close()
+
+ f = self.open(support.TESTFN, "r", encoding="euc_jp")
+ self.assertEqual(f.readline(), "AB\n")
+ p0 = f.tell()
+ self.assertEqual(f.readline(), "\u3046\u3048\n")
+ p1 = f.tell()
+ f.seek(p0)
+ self.assertEqual(f.readline(), "\u3046\u3048\n")
+ self.assertEqual(f.tell(), p1)
+ f.close()
+
+ def test_seek_with_encoder_state(self):
+ f = self.open(support.TESTFN, "w", encoding="euc_jis_2004")
+ f.write("\u00e6\u0300")
+ p0 = f.tell()
+ f.write("\u00e6")
+ f.seek(p0)
+ f.write("\u0300")
+ f.close()
+
+ f = self.open(support.TESTFN, "r", encoding="euc_jis_2004")
+ self.assertEqual(f.readline(), "\u00e6\u0300\u0300")
+ f.close()
+
def test_encoded_writes(self):
data = "1234567890"
tests = ("utf-16",
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 01a1cd3c693c..8e8362b70fd0 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -117,6 +117,88 @@ def test_stateful_keep_buffer(self):
self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
self.assertEqual(encoder.encode('', True), b'\xa9\xdc')
+ def test_state_methods_with_buffer_state(self):
+ # euc_jis_2004 stores state as a buffer of pending bytes
+ encoder = codecs.getincrementalencoder('euc_jis_2004')()
+
+ initial_state = encoder.getstate()
+ self.assertEqual(encoder.encode('\u00e6\u0300'), b'\xab\xc4')
+ encoder.setstate(initial_state)
+ self.assertEqual(encoder.encode('\u00e6\u0300'), b'\xab\xc4')
+
+ self.assertEqual(encoder.encode('\u00e6'), b'')
+ partial_state = encoder.getstate()
+ self.assertEqual(encoder.encode('\u0300'), b'\xab\xc4')
+ encoder.setstate(partial_state)
+ self.assertEqual(encoder.encode('\u0300'), b'\xab\xc4')
+
+ def test_state_methods_with_non_buffer_state(self):
+ # iso2022_jp stores state without using a buffer
+ encoder = codecs.getincrementalencoder('iso2022_jp')()
+
+ self.assertEqual(encoder.encode('z'), b'z')
+ en_state = encoder.getstate()
+
+ self.assertEqual(encoder.encode('\u3042'), b'\x1b\x24\x42\x24\x22')
+ jp_state = encoder.getstate()
+ self.assertEqual(encoder.encode('z'), b'\x1b\x28\x42z')
+
+ encoder.setstate(jp_state)
+ self.assertEqual(encoder.encode('\u3042'), b'\x24\x22')
+
+ encoder.setstate(en_state)
+ self.assertEqual(encoder.encode('z'), b'z')
+
+ def test_getstate_returns_expected_value(self):
+ # Note: getstate is implemented such that these state values
+ # are expected to be the same across all builds of Python,
+ # regardless of x32/64 bit, endianness and compiler.
+
+ # euc_jis_2004 stores state as a buffer of pending bytes
+ buffer_state_encoder = codecs.getincrementalencoder('euc_jis_2004')()
+ self.assertEqual(buffer_state_encoder.getstate(), 0)
+ buffer_state_encoder.encode('\u00e6')
+ self.assertEqual(buffer_state_encoder.getstate(),
+ int.from_bytes(
+ b"\x02"
+ b"\xc3\xa6"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00",
+ 'little'))
+ buffer_state_encoder.encode('\u0300')
+ self.assertEqual(buffer_state_encoder.getstate(), 0)
+
+ # iso2022_jp stores state without using a buffer
+ non_buffer_state_encoder = codecs.getincrementalencoder('iso2022_jp')()
+ self.assertEqual(non_buffer_state_encoder.getstate(),
+ int.from_bytes(
+ b"\x00"
+ b"\x42\x42\x00\x00\x00\x00\x00\x00",
+ 'little'))
+ non_buffer_state_encoder.encode('\u3042')
+ self.assertEqual(non_buffer_state_encoder.getstate(),
+ int.from_bytes(
+ b"\x00"
+ b"\xc2\x42\x00\x00\x00\x00\x00\x00",
+ 'little'))
+
+ def test_setstate_validates_input_size(self):
+ encoder = codecs.getincrementalencoder('euc_jp')()
+ pending_size_nine = int.from_bytes(
+ b"\x09"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00",
+ 'little')
+ self.assertRaises(UnicodeError, encoder.setstate, pending_size_nine)
+
+ def test_setstate_validates_input_bytes(self):
+ encoder = codecs.getincrementalencoder('euc_jp')()
+ invalid_utf8 = int.from_bytes(
+ b"\x01"
+ b"\xff"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00",
+ 'little')
+ self.assertRaises(UnicodeDecodeError, encoder.setstate, invalid_utf8)
+
def test_issue5640(self):
encoder = codecs.getincrementalencoder('shift-jis')('backslashreplace')
self.assertEqual(encoder.encode('\xff'), b'\\xff')
@@ -165,6 +247,37 @@ def test_decode_unicode(self):
decoder = codecs.getincrementaldecoder(enc)()
self.assertRaises(TypeError, decoder.decode, "")
+ def test_state_methods(self):
+ decoder = codecs.getincrementaldecoder('euc_jp')()
+
+ # Decode a complete input sequence
+ self.assertEqual(decoder.decode(b'\xa4\xa6'), '\u3046')
+ pending1, _ = decoder.getstate()
+ self.assertEqual(pending1, b'')
+
+ # Decode first half of a partial input sequence
+ self.assertEqual(decoder.decode(b'\xa4'), '')
+ pending2, flags2 = decoder.getstate()
+ self.assertEqual(pending2, b'\xa4')
+
+ # Decode second half of a partial input sequence
+ self.assertEqual(decoder.decode(b'\xa6'), '\u3046')
+ pending3, _ = decoder.getstate()
+ self.assertEqual(pending3, b'')
+
+ # Jump back and decode second half of partial input sequence again
+ decoder.setstate((pending2, flags2))
+ self.assertEqual(decoder.decode(b'\xa6'), '\u3046')
+ pending4, _ = decoder.getstate()
+ self.assertEqual(pending4, b'')
+
+ def test_setstate_validates_input(self):
+ decoder = codecs.getincrementaldecoder('euc_jp')()
+ self.assertRaises(TypeError, decoder.setstate, 123)
+ self.assertRaises(TypeError, decoder.setstate, ("invalid", 0))
+ self.assertRaises(TypeError, decoder.setstate, (b"1234", "invalid"))
+ self.assertRaises(UnicodeError, decoder.setstate, (b"123456789", 0))
+
class Test_StreamReader(unittest.TestCase):
def test_bug1728403(self):
try:
diff --git a/Misc/ACKS b/Misc/ACKS
index 043d604a3f96..08ff6d11fdd0 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1626,6 +1626,7 @@ Nicolas M. Thi?ry
James Thomas
Robin Thomas
Brian Thorne
+Christopher Thorne
Stephen Thorne
Jeremy Thurgood
Eric Tiedemann
diff --git a/Misc/NEWS.d/next/Library/2018-06-08-23-55-34.bpo-33578.7oSsjG.rst b/Misc/NEWS.d/next/Library/2018-06-08-23-55-34.bpo-33578.7oSsjG.rst
new file mode 100644
index 000000000000..4e2e4627dc54
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-06-08-23-55-34.bpo-33578.7oSsjG.rst
@@ -0,0 +1 @@
+Implement multibyte encoder/decoder state methods
diff --git a/Modules/cjkcodecs/_codecs_cn.c b/Modules/cjkcodecs/_codecs_cn.c
index 1fcc220b8db0..8a62f7e257c6 100644
--- a/Modules/cjkcodecs/_codecs_cn.c
+++ b/Modules/cjkcodecs/_codecs_cn.c
@@ -51,6 +51,12 @@
; \
}
+/*
+ * codecs in this file use the first byte of MultibyteCodec_State.c[8]
+ * to store a 0 or 1 state value
+ */
+#define CN_STATE_OFFSET 0
+
/*
* GB2312 codec
*/
@@ -329,15 +335,15 @@ DECODER(gb18030)
ENCODER_INIT(hz)
{
- state->i = 0;
+ state->c[CN_STATE_OFFSET] = 0;
return 0;
}
ENCODER_RESET(hz)
{
- if (state->i != 0) {
+ if (state->c[CN_STATE_OFFSET] != 0) {
WRITEBYTE2('~', '}');
- state->i = 0;
+ state->c[CN_STATE_OFFSET] = 0;
NEXT_OUT(2);
}
return 0;
@@ -350,10 +356,10 @@ ENCODER(hz)
DBCHAR code;
if (c < 0x80) {
- if (state->i) {
+ if (state->c[CN_STATE_OFFSET]) {
WRITEBYTE2('~', '}');
NEXT_OUT(2);
- state->i = 0;
+ state->c[CN_STATE_OFFSET] = 0;
}
WRITEBYTE1((unsigned char)c);
NEXT(1, 1);
@@ -375,10 +381,10 @@ ENCODER(hz)
if (code & 0x8000) /* MSB set: GBK */
return 1;
- if (state->i == 0) {
+ if (state->c[CN_STATE_OFFSET] == 0) {
WRITEBYTE4('~', '{', code >> 8, code & 0xff);
NEXT(1, 4);
- state->i = 1;
+ state->c[CN_STATE_OFFSET] = 1;
}
else {
WRITEBYTE2(code >> 8, code & 0xff);
@@ -391,13 +397,13 @@ ENCODER(hz)
DECODER_INIT(hz)
{
- state->i = 0;
+ state->c[CN_STATE_OFFSET] = 0;
return 0;
}
DECODER_RESET(hz)
{
- state->i = 0;
+ state->c[CN_STATE_OFFSET] = 0;
return 0;
}
@@ -411,14 +417,14 @@ DECODER(hz)
unsigned char c2 = INBYTE2;
REQUIRE_INBUF(2);
- if (c2 == '~' && state->i == 0)
+ if (c2 == '~' && state->c[CN_STATE_OFFSET] == 0)
OUTCHAR('~');
- else if (c2 == '{' && state->i == 0)
- state->i = 1; /* set GB */
- else if (c2 == '\n' && state->i == 0)
+ else if (c2 == '{' && state->c[CN_STATE_OFFSET] == 0)
+ state->c[CN_STATE_OFFSET] = 1; /* set GB */
+ else if (c2 == '\n' && state->c[CN_STATE_OFFSET] == 0)
; /* line-continuation */
- else if (c2 == '}' && state->i == 1)
- state->i = 0; /* set ASCII */
+ else if (c2 == '}' && state->c[CN_STATE_OFFSET] == 1)
+ state->c[CN_STATE_OFFSET] = 0; /* set ASCII */
else
return 1;
NEXT_IN(2);
@@ -428,7 +434,7 @@ DECODER(hz)
if (c & 0x80)
return 1;
- if (state->i == 0) { /* ASCII mode */
+ if (state->c[CN_STATE_OFFSET] == 0) { /* ASCII mode */
OUTCHAR(c);
NEXT_IN(1);
}
diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h
index 25857fc6d6f0..a58bb646a411 100644
--- a/Modules/cjkcodecs/clinic/multibytecodec.c.h
+++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h
@@ -115,6 +115,50 @@ _multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderOb
return return_value;
}
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_getstate__doc__,
+"getstate($self, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF \
+ {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_getstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_getstate(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(self);
+}
+
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_setstate__doc__,
+"setstate($self, state, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF \
+ {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalEncoder_setstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
+ PyLongObject *statelong);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoderObject *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ PyLongObject *statelong;
+
+ if (!PyArg_Parse(arg, "O!:setstate", &PyLong_Type, &statelong)) {
+ goto exit;
+ }
+ return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
+
+exit:
+ return return_value;
+}
+
PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_reset__doc__,
"reset($self, /)\n"
"--\n"
@@ -169,6 +213,50 @@ _multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderOb
return return_value;
}
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_getstate__doc__,
+"getstate($self, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF \
+ {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_getstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_getstate(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(self);
+}
+
+PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_setstate__doc__,
+"setstate($self, state, /)\n"
+"--\n"
+"\n");
+
+#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF \
+ {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalDecoder_setstate__doc__},
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
+ PyObject *state);
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoderObject *self, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ PyObject *state;
+
+ if (!PyArg_Parse(arg, "O!:setstate", &PyTuple_Type, &state)) {
+ goto exit;
+ }
+ return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
+
+exit:
+ return return_value;
+}
+
PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_reset__doc__,
"reset($self, /)\n"
"--\n"
@@ -330,4 +418,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
-/*[clinic end generated code: output=680f59f4cfe63c25 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2fa0a38494716b97 input=a9049054013a1b77]*/
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 22172b043bcd..4633499a8abf 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -895,6 +895,93 @@ _multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEnco
return encoder_encode_stateful(STATEFUL_ECTX(self), input, final);
}
+/*[clinic input]
+_multibytecodec.MultibyteIncrementalEncoder.getstate
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self)
+/*[clinic end generated code: output=9794a5ace70d7048 input=4a2a82874ffa40bb]*/
+{
+ /* state made up of 1 byte for buffer size, up to MAXENCPENDING*4 bytes
+ for UTF-8 encoded buffer (each character can use up to 4
+ bytes), and required bytes for MultibyteCodec_State.c. A byte
+ array is used to avoid different compilers generating different
+ values for the same state, e.g. as a result of struct padding.
+ */
+ unsigned char statebytes[1 + MAXENCPENDING*4 + sizeof(self->state.c)];
+ Py_ssize_t statesize;
+ const char *pendingbuffer = NULL;
+ Py_ssize_t pendingsize;
+
+ if (self->pending != NULL) {
+ pendingbuffer = PyUnicode_AsUTF8AndSize(self->pending, &pendingsize);
+ if (pendingbuffer == NULL) {
+ return NULL;
+ }
+ if (pendingsize > MAXENCPENDING*4) {
+ PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
+ return NULL;
+ }
+ statebytes[0] = pendingsize;
+ memcpy(statebytes+1, pendingbuffer, pendingsize);
+ statesize = 1 + pendingsize;
+ } else {
+ statebytes[0] = 0;
+ statesize = 1;
+ }
+ memcpy(statebytes+statesize, self->state.c,
+ sizeof(self->state.c));
+ statesize += sizeof(self->state.c);
+
+ return (PyObject *)_PyLong_FromByteArray(statebytes, statesize,
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ );
+}
+
+/*[clinic input]
+_multibytecodec.MultibyteIncrementalEncoder.setstate
+ state as statelong: object(type='PyLongObject *', subclass_of='&PyLong_Type')
+ /
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
+ PyLongObject *statelong)
+/*[clinic end generated code: output=4e5e98ac1f4039ca input=c80fb5830d4d2f76]*/
+{
+ PyObject *pending = NULL;
+ unsigned char statebytes[1 + MAXENCPENDING*4 + sizeof(self->state.c)];
+
+ if (_PyLong_AsByteArray(statelong, statebytes, sizeof(statebytes),
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ ) < 0) {
+ goto errorexit;
+ }
+
+ if (statebytes[0] > MAXENCPENDING*4) {
+ PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
+ return NULL;
+ }
+
+ pending = PyUnicode_DecodeUTF8((const char *)statebytes+1,
+ statebytes[0], "strict");
+ if (pending == NULL) {
+ goto errorexit;
+ }
+
+ Py_CLEAR(self->pending);
+ self->pending = pending;
+ memcpy(self->state.c, statebytes+1+statebytes[0],
+ sizeof(self->state.c));
+
+ Py_RETURN_NONE;
+
+errorexit:
+ Py_XDECREF(pending);
+ return NULL;
+}
+
/*[clinic input]
_multibytecodec.MultibyteIncrementalEncoder.reset
[clinic start generated code]*/
@@ -919,6 +1006,8 @@ _multibytecodec_MultibyteIncrementalEncoder_reset_impl(MultibyteIncrementalEncod
static struct PyMethodDef mbiencoder_methods[] = {
_MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF
_MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_RESET_METHODDEF
{NULL, NULL},
};
@@ -984,6 +1073,7 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self)
{
PyObject_GC_UnTrack(self);
ERROR_DECREF(self->errors);
+ Py_CLEAR(self->pending);
Py_TYPE(self)->tp_free(self);
}
@@ -1119,6 +1209,68 @@ _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDeco
return NULL;
}
+/*[clinic input]
+_multibytecodec.MultibyteIncrementalDecoder.getstate
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self)
+/*[clinic end generated code: output=255009c4713b7f82 input=4006aa49bddbaa75]*/
+{
+ PyObject *buffer;
+
+ buffer = PyBytes_FromStringAndSize((const char *)self->pending,
+ self->pendingsize);
+ if (buffer == NULL) {
+ return NULL;
+ }
+
+ return make_tuple(buffer, (Py_ssize_t)*self->state.c);
+}
+
+/*[clinic input]
+_multibytecodec.MultibyteIncrementalDecoder.setstate
+ state: object(subclass_of='&PyTuple_Type')
+ /
+[clinic start generated code]*/
+
+static PyObject *
+_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
+ PyObject *state)
+/*[clinic end generated code: output=106b2fbca3e2dcc2 input=e5d794e8baba1a47]*/
+{
+ PyObject *buffer;
+ Py_ssize_t buffersize;
+ char *bufferstr;
+ unsigned long long flag;
+
+ if (!PyArg_ParseTuple(state, "SK;setstate(): illegal state argument",
+ &buffer, &flag))
+ {
+ return NULL;
+ }
+
+ buffersize = PyBytes_Size(buffer);
+ if (buffersize == -1) {
+ return NULL;
+ }
+
+ if (buffersize > MAXDECPENDING) {
+ PyErr_SetString(PyExc_UnicodeError, "pending buffer too large");
+ return NULL;
+ }
+
+ bufferstr = PyBytes_AsString(buffer);
+ if (bufferstr == NULL) {
+ return NULL;
+ }
+ self->pendingsize = buffersize;
+ memcpy(self->pending, bufferstr, self->pendingsize);
+ memcpy(self->state.c, (unsigned char *)&flag, sizeof(flag));
+
+ Py_RETURN_NONE;
+}
+
/*[clinic input]
_multibytecodec.MultibyteIncrementalDecoder.reset
[clinic start generated code]*/
@@ -1137,6 +1289,8 @@ _multibytecodec_MultibyteIncrementalDecoder_reset_impl(MultibyteIncrementalDecod
static struct PyMethodDef mbidecoder_methods[] = {
_MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF
+ _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF
_MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_RESET_METHODDEF
{NULL, NULL},
};
diff --git a/Modules/cjkcodecs/multibytecodec.h b/Modules/cjkcodecs/multibytecodec.h
index 5b8c22276b4b..6d34534ee685 100644
--- a/Modules/cjkcodecs/multibytecodec.h
+++ b/Modules/cjkcodecs/multibytecodec.h
@@ -16,12 +16,15 @@ typedef uint16_t ucs2_t, DBCHAR;
typedef unsigned short ucs2_t, DBCHAR;
#endif
-typedef union {
- void *p;
- int i;
+/*
+ * A struct that provides 8 bytes of state for multibyte
+ * codecs. Codecs are free to use this how they want. Note: if you
+ * need to add a new field to this struct, ensure that its byte order
+ * is independent of CPU endianness so that the return value of
+ * getstate doesn't differ between little and big endian CPUs.
+ */
+typedef struct {
unsigned char c[8];
- ucs2_t u2[4];
- Py_UCS4 u4[2];
} MultibyteCodec_State;
typedef int (*mbcodec_init)(const void *config);
From webhook-mailer at python.org Thu Nov 1 08:19:28 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Thu, 01 Nov 2018 12:19:28 -0000
Subject: [Python-checkins] [3.7] bpo-35128: Fix spacing issues in
warning.warn() messages. (GH-10268). (GH-10280)
Message-ID:
https://github.com/python/cpython/commit/5e0537cf7e5b0a5ef134c7da0b68b8e55c69f4b0
commit: 5e0537cf7e5b0a5ef134c7da0b68b8e55c69f4b0
branch: 3.7
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-01T14:19:23+02:00
summary:
[3.7] bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268). (GH-10280)
(cherry picked from commit 4b5e62dbb22a3593e0db266c12f805b727a42b00)
Co-authored-by: Pablo Aguiar
files:
M Lib/ftplib.py
M Lib/imaplib.py
M Lib/poplib.py
M Lib/smtplib.py
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 05840d492360..9611282ecacb 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -732,7 +732,7 @@ def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index e451413acf5a..dd237f7704ac 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -1277,7 +1277,7 @@ def __init__(self, host='', port=IMAP4_SSL_PORT, keyfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom ssl_context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/poplib.py b/Lib/poplib.py
index d8a62c034327..9796f0d2f9c5 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -436,7 +436,7 @@ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 5e1bc0b198ed..6091c7fb7aca 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -762,7 +762,7 @@ def starttls(self, keyfile=None, certfile=None, context=None):
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
if context is None:
context = ssl._create_stdlib_context(certfile=certfile,
@@ -1019,7 +1019,7 @@ def __init__(self, host='', port=0, local_hostname=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
From webhook-mailer at python.org Thu Nov 1 08:19:41 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Thu, 01 Nov 2018 12:19:41 -0000
Subject: [Python-checkins] [3.6] bpo-35128: Fix spacing issues in
warning.warn() messages. (GH-10268). (GH-10281)
Message-ID:
https://github.com/python/cpython/commit/89138f286938753f273c90547491efe374e617c1
commit: 89138f286938753f273c90547491efe374e617c1
branch: 3.6
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-01T14:19:37+02:00
summary:
[3.6] bpo-35128: Fix spacing issues in warning.warn() messages. (GH-10268). (GH-10281)
(cherry picked from commit 4b5e62dbb22a3593e0db266c12f805b727a42b00)
Co-authored-by: Pablo Aguiar
files:
M Lib/ftplib.py
M Lib/imaplib.py
M Lib/poplib.py
M Lib/smtplib.py
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index a02e595cb022..2ff251a0f7d9 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -732,7 +732,7 @@ def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index b9a01d636f78..67b2cc02c40f 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -1277,7 +1277,7 @@ def __init__(self, host='', port=IMAP4_SSL_PORT, keyfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom ssl_context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/poplib.py b/Lib/poplib.py
index d8a62c034327..9796f0d2f9c5 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -436,7 +436,7 @@ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 5e1bc0b198ed..6091c7fb7aca 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -762,7 +762,7 @@ def starttls(self, keyfile=None, certfile=None, context=None):
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
if context is None:
context = ssl._create_stdlib_context(certfile=certfile,
@@ -1019,7 +1019,7 @@ def __init__(self, host='', port=0, local_hostname=None,
"exclusive")
if keyfile is not None or certfile is not None:
import warnings
- warnings.warn("keyfile and certfile are deprecated, use a"
+ warnings.warn("keyfile and certfile are deprecated, use a "
"custom context instead", DeprecationWarning, 2)
self.keyfile = keyfile
self.certfile = certfile
From webhook-mailer at python.org Thu Nov 1 08:29:44 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 12:29:44 -0000
Subject: [Python-checkins] bpo-35075: Fix broken url in the pprint
documentation (GH-10201)
Message-ID:
https://github.com/python/cpython/commit/bf46a09dec372b85846216bd692d648dac08ac36
commit: bf46a09dec372b85846216bd692d648dac08ac36
branch: master
author: Pablo Galindo
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-11-01T05:29:38-07:00
summary:
bpo-35075: Fix broken url in the pprint documentation (GH-10201)
https://bugs.python.org/issue35075
files:
M Doc/library/pprint.rst
M Doc/tools/susp-ignored.csv
diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst
index aa97d3eabafa..3922a768311c 100644
--- a/Doc/library/pprint.rst
+++ b/Doc/library/pprint.rst
@@ -217,135 +217,156 @@ let's fetch information about a project from `PyPI `_::
>>> import json
>>> import pprint
>>> from urllib.request import urlopen
- >>> with urlopen('http://pypi.org/project/Twisted/json') as url:
- ... http_info = url.info()
- ... raw_data = url.read().decode(http_info.get_content_charset())
- >>> project_info = json.loads(raw_data)
+ >>> with urlopen('https://pypi.org/pypi/sampleproject/json') as resp:
+ ... project_info = json.load(resp)['info']
In its basic form, :func:`pprint` shows the whole object::
>>> pprint.pprint(project_info)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': ['Programming Language :: Python :: 2.6',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 2 :: Only'],
- 'description': 'An extensible framework for Python programming, with '
- 'special focus\r\n'
- 'on event-based network programming and multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking framework written in Python',
- 'version': '12.3.0'},
- 'urls': [{'comment_text': '',
- 'downloads': 71844,
- 'filename': 'Twisted-12.3.0.tar.bz2',
- 'has_sig': False,
- 'md5_digest': '6e289825f3bf5591cfd670874cc0862d',
- 'packagetype': 'sdist',
- 'python_version': 'source',
- 'size': 2615733,
- 'upload_time': '2012-12-26T12:47:03',
- 'url': 'https://pypi.org/packages/source/T/Twisted/Twisted-12.3.0.tar.bz2'},
- {'comment_text': '',
- 'downloads': 5224,
- 'filename': 'Twisted-12.3.0.win32-py2.7.msi',
- 'has_sig': False,
- 'md5_digest': '6b778f5201b622a5519a2aca1a2fe512',
- 'packagetype': 'bdist_msi',
- 'python_version': '2.7',
- 'size': 2916352,
- 'upload_time': '2012-12-26T12:48:15',
- 'url': 'https://pypi.org/packages/2.7/T/Twisted/Twisted-12.3.0.win32-py2.7.msi'}]}
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': ['Development Status :: 3 - Alpha',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.2',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Topic :: Software Development :: Build Tools'],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be written using '
+ 'ReStructured Text. It\n'
+ 'will be used to generate the project webpage on PyPI, and '
+ 'should be written for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would include an overview of '
+ 'the project, basic\n'
+ 'usage examples, etc. Generally, including the project '
+ 'changelog in here is not\n'
+ 'a good idea, although a simple "What\'s New" section for the '
+ 'most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {'Download': 'UNKNOWN',
+ 'Homepage': 'https://github.com/pypa/sampleproject'},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
The result can be limited to a certain *depth* (ellipsis is used for deeper
contents)::
- >>> pprint.pprint(project_info, depth=2)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': [...],
- 'description': 'An extensible framework for Python programming, with '
- 'special focus\r\n'
- 'on event-based network programming and multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking framework written in Python',
- 'version': '12.3.0'},
- 'urls': [{...}, {...}]}
+ >>> pprint.pprint(project_info, depth=1)
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': [...],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be written using '
+ 'ReStructured Text. It\n'
+ 'will be used to generate the project webpage on PyPI, and '
+ 'should be written for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would include an overview of '
+ 'the project, basic\n'
+ 'usage examples, etc. Generally, including the project '
+ 'changelog in here is not\n'
+ 'a good idea, although a simple "What\'s New" section for the '
+ 'most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {...},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {...},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
Additionally, maximum character *width* can be suggested. If a long object
cannot be split, the specified width will be exceeded::
- >>> pprint.pprint(project_info, depth=2, width=50)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': [...],
- 'description': 'An extensible '
- 'framework for Python '
- 'programming, with '
- 'special focus\r\n'
- 'on event-based network '
- 'programming and '
- 'multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking '
- 'framework written in '
- 'Python',
- 'version': '12.3.0'},
- 'urls': [{...}, {...}]}
+ >>> pprint.pprint(project_info, depth=1, width=60)
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': [...],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the '
+ 'project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be '
+ 'written using ReStructured Text. It\n'
+ 'will be used to generate the project '
+ 'webpage on PyPI, and should be written '
+ 'for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would '
+ 'include an overview of the project, '
+ 'basic\n'
+ 'usage examples, etc. Generally, including '
+ 'the project changelog in here is not\n'
+ 'a good idea, although a simple "What\'s '
+ 'New" section for the most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {...},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {...},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv
index bb3310bac75f..118ac1554b59 100644
--- a/Doc/tools/susp-ignored.csv
+++ b/Doc/tools/susp-ignored.csv
@@ -178,9 +178,17 @@ library/pathlib,,:Program,>>> PureWindowsPath('c:Program Files/').anchor
library/pdb,,:lineno,filename:lineno
library/pickle,,:memory,"conn = sqlite3.connect("":memory:"")"
library/posix,,`,"CFLAGS=""`getconf LFS_CFLAGS`"" OPT=""-g -O2 $CFLAGS"""
-library/pprint,,::,"'Programming Language :: Python :: 2 :: Only'],"
library/pprint,,::,"'Programming Language :: Python :: 2.6',"
library/pprint,,::,"'Programming Language :: Python :: 2.7',"
+library/pprint,225,::,"'classifiers': ['Development Status :: 3 - Alpha',"
+library/pprint,225,::,"'Intended Audience :: Developers',"
+library/pprint,225,::,"'License :: OSI Approved :: MIT License',"
+library/pprint,225,::,"'Programming Language :: Python :: 2',"
+library/pprint,225,::,"'Programming Language :: Python :: 3',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.2',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.3',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.4',"
+library/pprint,225,::,"'Topic :: Software Development :: Build Tools'],"
library/profile,,:lineno,filename:lineno(function)
library/pyexpat,,:elem1,
library/pyexpat,,:py,"xmlns:py = ""http://www.python.org/ns/"">"
From webhook-mailer at python.org Thu Nov 1 09:37:34 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 13:37:34 -0000
Subject: [Python-checkins] bpo-35075: Fix broken url in the pprint
documentation (GH-10201)
Message-ID:
https://github.com/python/cpython/commit/7344b9fa0ef7bd8b902e7aa9a8f74b5dce915e59
commit: 7344b9fa0ef7bd8b902e7aa9a8f74b5dce915e59
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T06:37:28-07:00
summary:
bpo-35075: Fix broken url in the pprint documentation (GH-10201)
https://bugs.python.org/issue35075
(cherry picked from commit bf46a09dec372b85846216bd692d648dac08ac36)
Co-authored-by: Pablo Galindo
files:
M Doc/library/pprint.rst
M Doc/tools/susp-ignored.csv
diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst
index aa97d3eabafa..3922a768311c 100644
--- a/Doc/library/pprint.rst
+++ b/Doc/library/pprint.rst
@@ -217,135 +217,156 @@ let's fetch information about a project from `PyPI `_::
>>> import json
>>> import pprint
>>> from urllib.request import urlopen
- >>> with urlopen('http://pypi.org/project/Twisted/json') as url:
- ... http_info = url.info()
- ... raw_data = url.read().decode(http_info.get_content_charset())
- >>> project_info = json.loads(raw_data)
+ >>> with urlopen('https://pypi.org/pypi/sampleproject/json') as resp:
+ ... project_info = json.load(resp)['info']
In its basic form, :func:`pprint` shows the whole object::
>>> pprint.pprint(project_info)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': ['Programming Language :: Python :: 2.6',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 2 :: Only'],
- 'description': 'An extensible framework for Python programming, with '
- 'special focus\r\n'
- 'on event-based network programming and multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking framework written in Python',
- 'version': '12.3.0'},
- 'urls': [{'comment_text': '',
- 'downloads': 71844,
- 'filename': 'Twisted-12.3.0.tar.bz2',
- 'has_sig': False,
- 'md5_digest': '6e289825f3bf5591cfd670874cc0862d',
- 'packagetype': 'sdist',
- 'python_version': 'source',
- 'size': 2615733,
- 'upload_time': '2012-12-26T12:47:03',
- 'url': 'https://pypi.org/packages/source/T/Twisted/Twisted-12.3.0.tar.bz2'},
- {'comment_text': '',
- 'downloads': 5224,
- 'filename': 'Twisted-12.3.0.win32-py2.7.msi',
- 'has_sig': False,
- 'md5_digest': '6b778f5201b622a5519a2aca1a2fe512',
- 'packagetype': 'bdist_msi',
- 'python_version': '2.7',
- 'size': 2916352,
- 'upload_time': '2012-12-26T12:48:15',
- 'url': 'https://pypi.org/packages/2.7/T/Twisted/Twisted-12.3.0.win32-py2.7.msi'}]}
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': ['Development Status :: 3 - Alpha',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.2',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Topic :: Software Development :: Build Tools'],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be written using '
+ 'ReStructured Text. It\n'
+ 'will be used to generate the project webpage on PyPI, and '
+ 'should be written for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would include an overview of '
+ 'the project, basic\n'
+ 'usage examples, etc. Generally, including the project '
+ 'changelog in here is not\n'
+ 'a good idea, although a simple "What\'s New" section for the '
+ 'most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {'Download': 'UNKNOWN',
+ 'Homepage': 'https://github.com/pypa/sampleproject'},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
The result can be limited to a certain *depth* (ellipsis is used for deeper
contents)::
- >>> pprint.pprint(project_info, depth=2)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': [...],
- 'description': 'An extensible framework for Python programming, with '
- 'special focus\r\n'
- 'on event-based network programming and multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking framework written in Python',
- 'version': '12.3.0'},
- 'urls': [{...}, {...}]}
+ >>> pprint.pprint(project_info, depth=1)
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': [...],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be written using '
+ 'ReStructured Text. It\n'
+ 'will be used to generate the project webpage on PyPI, and '
+ 'should be written for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would include an overview of '
+ 'the project, basic\n'
+ 'usage examples, etc. Generally, including the project '
+ 'changelog in here is not\n'
+ 'a good idea, although a simple "What\'s New" section for the '
+ 'most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {...},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {...},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
Additionally, maximum character *width* can be suggested. If a long object
cannot be split, the specified width will be exceeded::
- >>> pprint.pprint(project_info, depth=2, width=50)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': [...],
- 'description': 'An extensible '
- 'framework for Python '
- 'programming, with '
- 'special focus\r\n'
- 'on event-based network '
- 'programming and '
- 'multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking '
- 'framework written in '
- 'Python',
- 'version': '12.3.0'},
- 'urls': [{...}, {...}]}
+ >>> pprint.pprint(project_info, depth=1, width=60)
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': [...],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the '
+ 'project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be '
+ 'written using ReStructured Text. It\n'
+ 'will be used to generate the project '
+ 'webpage on PyPI, and should be written '
+ 'for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would '
+ 'include an overview of the project, '
+ 'basic\n'
+ 'usage examples, etc. Generally, including '
+ 'the project changelog in here is not\n'
+ 'a good idea, although a simple "What\'s '
+ 'New" section for the most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {...},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {...},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv
index 482ffc0bde8a..e9bee8b5e1b8 100644
--- a/Doc/tools/susp-ignored.csv
+++ b/Doc/tools/susp-ignored.csv
@@ -180,9 +180,17 @@ library/pathlib,,:Program,>>> PureWindowsPath('c:Program Files/').anchor
library/pdb,,:lineno,filename:lineno
library/pickle,,:memory,"conn = sqlite3.connect("":memory:"")"
library/posix,,`,"CFLAGS=""`getconf LFS_CFLAGS`"" OPT=""-g -O2 $CFLAGS"""
-library/pprint,,::,"'Programming Language :: Python :: 2 :: Only'],"
library/pprint,,::,"'Programming Language :: Python :: 2.6',"
library/pprint,,::,"'Programming Language :: Python :: 2.7',"
+library/pprint,225,::,"'classifiers': ['Development Status :: 3 - Alpha',"
+library/pprint,225,::,"'Intended Audience :: Developers',"
+library/pprint,225,::,"'License :: OSI Approved :: MIT License',"
+library/pprint,225,::,"'Programming Language :: Python :: 2',"
+library/pprint,225,::,"'Programming Language :: Python :: 3',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.2',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.3',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.4',"
+library/pprint,225,::,"'Topic :: Software Development :: Build Tools'],"
library/profile,,:lineno,filename:lineno(function)
library/pyexpat,,:elem1,
library/pyexpat,,:py,"xmlns:py = ""http://www.python.org/ns/"">"
From webhook-mailer at python.org Thu Nov 1 13:25:10 2018
From: webhook-mailer at python.org (Barry Warsaw)
Date: Thu, 01 Nov 2018 17:25:10 -0000
Subject: [Python-checkins] Simplify sys.breakpointhook implementation (#9519)
Message-ID:
https://github.com/python/cpython/commit/dce345c51abd5081679a487315fb47efddc54cdb
commit: dce345c51abd5081679a487315fb47efddc54cdb
branch: master
author: Anthony Sottile
committer: Barry Warsaw
date: 2018-11-01T10:25:05-07:00
summary:
Simplify sys.breakpointhook implementation (#9519)
files:
M Python/sysmodule.c
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 21647083d683..c0f168c63820 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -151,16 +151,8 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
return NULL;
}
- PyObject *fromlist = Py_BuildValue("(s)", attrname);
- if (fromlist == NULL) {
- Py_DECREF(modulepath);
- PyMem_RawFree(envar);
- return NULL;
- }
- PyObject *module = PyImport_ImportModuleLevelObject(
- modulepath, NULL, NULL, fromlist, 0);
+ PyObject *module = PyImport_Import(modulepath);
Py_DECREF(modulepath);
- Py_DECREF(fromlist);
if (module == NULL) {
goto error;
From webhook-mailer at python.org Thu Nov 1 17:33:58 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 21:33:58 -0000
Subject: [Python-checkins] bpo-35075: Fix broken url in the pprint
documentation (GH-10201)
Message-ID:
https://github.com/python/cpython/commit/7d35553138d8b2799ae68601ce836a3647509718
commit: 7d35553138d8b2799ae68601ce836a3647509718
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T14:33:52-07:00
summary:
bpo-35075: Fix broken url in the pprint documentation (GH-10201)
https://bugs.python.org/issue35075
(cherry picked from commit bf46a09dec372b85846216bd692d648dac08ac36)
Co-authored-by: Pablo Galindo
files:
M Doc/library/pprint.rst
M Doc/tools/susp-ignored.csv
diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst
index aa97d3eabafa..3922a768311c 100644
--- a/Doc/library/pprint.rst
+++ b/Doc/library/pprint.rst
@@ -217,135 +217,156 @@ let's fetch information about a project from `PyPI `_::
>>> import json
>>> import pprint
>>> from urllib.request import urlopen
- >>> with urlopen('http://pypi.org/project/Twisted/json') as url:
- ... http_info = url.info()
- ... raw_data = url.read().decode(http_info.get_content_charset())
- >>> project_info = json.loads(raw_data)
+ >>> with urlopen('https://pypi.org/pypi/sampleproject/json') as resp:
+ ... project_info = json.load(resp)['info']
In its basic form, :func:`pprint` shows the whole object::
>>> pprint.pprint(project_info)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': ['Programming Language :: Python :: 2.6',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 2 :: Only'],
- 'description': 'An extensible framework for Python programming, with '
- 'special focus\r\n'
- 'on event-based network programming and multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking framework written in Python',
- 'version': '12.3.0'},
- 'urls': [{'comment_text': '',
- 'downloads': 71844,
- 'filename': 'Twisted-12.3.0.tar.bz2',
- 'has_sig': False,
- 'md5_digest': '6e289825f3bf5591cfd670874cc0862d',
- 'packagetype': 'sdist',
- 'python_version': 'source',
- 'size': 2615733,
- 'upload_time': '2012-12-26T12:47:03',
- 'url': 'https://pypi.org/packages/source/T/Twisted/Twisted-12.3.0.tar.bz2'},
- {'comment_text': '',
- 'downloads': 5224,
- 'filename': 'Twisted-12.3.0.win32-py2.7.msi',
- 'has_sig': False,
- 'md5_digest': '6b778f5201b622a5519a2aca1a2fe512',
- 'packagetype': 'bdist_msi',
- 'python_version': '2.7',
- 'size': 2916352,
- 'upload_time': '2012-12-26T12:48:15',
- 'url': 'https://pypi.org/packages/2.7/T/Twisted/Twisted-12.3.0.win32-py2.7.msi'}]}
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': ['Development Status :: 3 - Alpha',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.2',
+ 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Topic :: Software Development :: Build Tools'],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be written using '
+ 'ReStructured Text. It\n'
+ 'will be used to generate the project webpage on PyPI, and '
+ 'should be written for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would include an overview of '
+ 'the project, basic\n'
+ 'usage examples, etc. Generally, including the project '
+ 'changelog in here is not\n'
+ 'a good idea, although a simple "What\'s New" section for the '
+ 'most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {'Download': 'UNKNOWN',
+ 'Homepage': 'https://github.com/pypa/sampleproject'},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
The result can be limited to a certain *depth* (ellipsis is used for deeper
contents)::
- >>> pprint.pprint(project_info, depth=2)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': [...],
- 'description': 'An extensible framework for Python programming, with '
- 'special focus\r\n'
- 'on event-based network programming and multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking framework written in Python',
- 'version': '12.3.0'},
- 'urls': [{...}, {...}]}
+ >>> pprint.pprint(project_info, depth=1)
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': [...],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be written using '
+ 'ReStructured Text. It\n'
+ 'will be used to generate the project webpage on PyPI, and '
+ 'should be written for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would include an overview of '
+ 'the project, basic\n'
+ 'usage examples, etc. Generally, including the project '
+ 'changelog in here is not\n'
+ 'a good idea, although a simple "What\'s New" section for the '
+ 'most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {...},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {...},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
Additionally, maximum character *width* can be suggested. If a long object
cannot be split, the specified width will be exceeded::
- >>> pprint.pprint(project_info, depth=2, width=50)
- {'info': {'_pypi_hidden': False,
- '_pypi_ordering': 125,
- 'author': 'Glyph Lefkowitz',
- 'author_email': 'glyph at twistedmatrix.com',
- 'bugtrack_url': '',
- 'cheesecake_code_kwalitee_id': None,
- 'cheesecake_documentation_id': None,
- 'cheesecake_installability_id': None,
- 'classifiers': [...],
- 'description': 'An extensible '
- 'framework for Python '
- 'programming, with '
- 'special focus\r\n'
- 'on event-based network '
- 'programming and '
- 'multiprotocol '
- 'integration.',
- 'docs_url': '',
- 'download_url': 'UNKNOWN',
- 'home_page': 'http://twistedmatrix.com/',
- 'keywords': '',
- 'license': 'MIT',
- 'maintainer': '',
- 'maintainer_email': '',
- 'name': 'Twisted',
- 'package_url': 'http://pypi.org/project/Twisted',
- 'platform': 'UNKNOWN',
- 'release_url': 'http://pypi.org/project/Twisted/12.3.0',
- 'requires_python': None,
- 'stable_version': None,
- 'summary': 'An asynchronous networking '
- 'framework written in '
- 'Python',
- 'version': '12.3.0'},
- 'urls': [{...}, {...}]}
+ >>> pprint.pprint(project_info, depth=1, width=60)
+ {'author': 'The Python Packaging Authority',
+ 'author_email': 'pypa-dev at googlegroups.com',
+ 'bugtrack_url': None,
+ 'classifiers': [...],
+ 'description': 'A sample Python project\n'
+ '=======================\n'
+ '\n'
+ 'This is the description file for the '
+ 'project.\n'
+ '\n'
+ 'The file should use UTF-8 encoding and be '
+ 'written using ReStructured Text. It\n'
+ 'will be used to generate the project '
+ 'webpage on PyPI, and should be written '
+ 'for\n'
+ 'that purpose.\n'
+ '\n'
+ 'Typical contents for this file would '
+ 'include an overview of the project, '
+ 'basic\n'
+ 'usage examples, etc. Generally, including '
+ 'the project changelog in here is not\n'
+ 'a good idea, although a simple "What\'s '
+ 'New" section for the most recent version\n'
+ 'may be appropriate.',
+ 'description_content_type': None,
+ 'docs_url': None,
+ 'download_url': 'UNKNOWN',
+ 'downloads': {...},
+ 'home_page': 'https://github.com/pypa/sampleproject',
+ 'keywords': 'sample setuptools development',
+ 'license': 'MIT',
+ 'maintainer': None,
+ 'maintainer_email': None,
+ 'name': 'sampleproject',
+ 'package_url': 'https://pypi.org/project/sampleproject/',
+ 'platform': 'UNKNOWN',
+ 'project_url': 'https://pypi.org/project/sampleproject/',
+ 'project_urls': {...},
+ 'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
+ 'requires_dist': None,
+ 'requires_python': None,
+ 'summary': 'A sample Python project',
+ 'version': '1.2.0'}
diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv
index 33cd48f3d81e..0c78f8d3b333 100644
--- a/Doc/tools/susp-ignored.csv
+++ b/Doc/tools/susp-ignored.csv
@@ -180,9 +180,17 @@ library/pathlib,,:Program,>>> PureWindowsPath('c:Program Files/').anchor
library/pdb,,:lineno,filename:lineno
library/pickle,,:memory,"conn = sqlite3.connect("":memory:"")"
library/posix,,`,"CFLAGS=""`getconf LFS_CFLAGS`"" OPT=""-g -O2 $CFLAGS"""
-library/pprint,,::,"'Programming Language :: Python :: 2 :: Only'],"
library/pprint,,::,"'Programming Language :: Python :: 2.6',"
library/pprint,,::,"'Programming Language :: Python :: 2.7',"
+library/pprint,225,::,"'classifiers': ['Development Status :: 3 - Alpha',"
+library/pprint,225,::,"'Intended Audience :: Developers',"
+library/pprint,225,::,"'License :: OSI Approved :: MIT License',"
+library/pprint,225,::,"'Programming Language :: Python :: 2',"
+library/pprint,225,::,"'Programming Language :: Python :: 3',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.2',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.3',"
+library/pprint,225,::,"'Programming Language :: Python :: 3.4',"
+library/pprint,225,::,"'Topic :: Software Development :: Build Tools'],"
library/profile,,:lineno,filename:lineno(function)
library/pyexpat,,:elem1,
library/pyexpat,,:py,"xmlns:py = ""http://www.python.org/ns/"">"
From webhook-mailer at python.org Thu Nov 1 17:34:46 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 21:34:46 -0000
Subject: [Python-checkins] Doc: fix asyncio loop.close() description
(GH-10229)
Message-ID:
https://github.com/python/cpython/commit/d69f015ba5e617f6e15e2dcaefa095b83bc40448
commit: d69f015ba5e617f6e15e2dcaefa095b83bc40448
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T14:34:42-07:00
summary:
Doc: fix asyncio loop.close() description (GH-10229)
Needs backport to 3.7. In 3.6 the description is correct.
(cherry picked from commit b83d917fafd87e4130f9c7d5209ad2debc7219cd)
Co-authored-by: Andriy Maletsky
files:
M Doc/library/asyncio-eventloop.rst
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index df453cdfb7d8..8215198ce91f 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -137,7 +137,7 @@ Running and stopping the loop
Close the event loop.
- The loop must be running when this function is called.
+ The loop must not be running when this function is called.
Any pending callbacks will be discarded.
This method clears all queues and shuts down the executor, but does
From webhook-mailer at python.org Thu Nov 1 17:35:20 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 21:35:20 -0000
Subject: [Python-checkins] Include memo in the documented signature of
copy.deepcopy()
Message-ID:
https://github.com/python/cpython/commit/b9c48a73bc26ee7c16df2a07e84d330b5474a643
commit: b9c48a73bc26ee7c16df2a07e84d330b5474a643
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T14:35:17-07:00
summary:
Include memo in the documented signature of copy.deepcopy()
* Include memo in the documented signature of copy.deepcopy()
The memo argument is mentioned lower on the doc page under writing a
`__deepcopy__` method, but is not included in the documented function signature.
This makes it easy to miss, and can lead to incorrect/buggy implementations of
`__deepcopy__` -- which is exatly what just happpend to me!
(cherry picked from commit 0200928e8df012d408530b06a98119024bc82511)
Co-authored-by: Stephan Hoyer
files:
M Doc/library/copy.rst
diff --git a/Doc/library/copy.rst b/Doc/library/copy.rst
index 2041d9175ea5..c7bd89f96372 100644
--- a/Doc/library/copy.rst
+++ b/Doc/library/copy.rst
@@ -22,7 +22,7 @@ Interface summary:
Return a shallow copy of *x*.
-.. function:: deepcopy(x)
+.. function:: deepcopy(x[, memo])
Return a deep copy of *x*.
@@ -52,7 +52,7 @@ copy operations:
The :func:`deepcopy` function avoids these problems by:
-* keeping a "memo" dictionary of objects already copied during the current
+* keeping a ``memo`` dictionary of objects already copied during the current
copying pass; and
* letting user-defined classes override the copying operation or the set of
@@ -82,7 +82,7 @@ In order for a class to define its own copy implementation, it can define
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
to implement the shallow copy operation; no additional arguments are passed.
The latter is called to implement the deep copy operation; it is passed one
-argument, the memo dictionary. If the :meth:`__deepcopy__` implementation needs
+argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the memo dictionary as second argument.
From webhook-mailer at python.org Thu Nov 1 17:35:29 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Thu, 01 Nov 2018 21:35:29 -0000
Subject: [Python-checkins] Include memo in the documented signature of
copy.deepcopy()
Message-ID:
https://github.com/python/cpython/commit/49171877ddbbcb9b9a38b30e698ee9f8b826b297
commit: 49171877ddbbcb9b9a38b30e698ee9f8b826b297
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T14:35:26-07:00
summary:
Include memo in the documented signature of copy.deepcopy()
* Include memo in the documented signature of copy.deepcopy()
The memo argument is mentioned lower on the doc page under writing a
`__deepcopy__` method, but is not included in the documented function signature.
This makes it easy to miss, and can lead to incorrect/buggy implementations of
`__deepcopy__` -- which is exatly what just happpend to me!
(cherry picked from commit 0200928e8df012d408530b06a98119024bc82511)
Co-authored-by: Stephan Hoyer
files:
M Doc/library/copy.rst
diff --git a/Doc/library/copy.rst b/Doc/library/copy.rst
index 2041d9175ea5..c7bd89f96372 100644
--- a/Doc/library/copy.rst
+++ b/Doc/library/copy.rst
@@ -22,7 +22,7 @@ Interface summary:
Return a shallow copy of *x*.
-.. function:: deepcopy(x)
+.. function:: deepcopy(x[, memo])
Return a deep copy of *x*.
@@ -52,7 +52,7 @@ copy operations:
The :func:`deepcopy` function avoids these problems by:
-* keeping a "memo" dictionary of objects already copied during the current
+* keeping a ``memo`` dictionary of objects already copied during the current
copying pass; and
* letting user-defined classes override the copying operation or the set of
@@ -82,7 +82,7 @@ In order for a class to define its own copy implementation, it can define
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
to implement the shallow copy operation; no additional arguments are passed.
The latter is called to implement the deep copy operation; it is passed one
-argument, the memo dictionary. If the :meth:`__deepcopy__` implementation needs
+argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the memo dictionary as second argument.
From webhook-mailer at python.org Thu Nov 1 22:49:50 2018
From: webhook-mailer at python.org (Benjamin Peterson)
Date: Fri, 02 Nov 2018 02:49:50 -0000
Subject: [Python-checkins] closes bpo-35139: The `pyexpat` module's macros
in `Modules/Setup` now match `setup.py` (GH-10289)
Message-ID:
https://github.com/python/cpython/commit/318ab63c01f5b8e7562b122ab5ba01258a51277b
commit: 318ab63c01f5b8e7562b122ab5ba01258a51277b
branch: master
author: Max B?langer
committer: Benjamin Peterson
date: 2018-11-01T19:49:46-07:00
summary:
closes bpo-35139: The `pyexpat` module's macros in `Modules/Setup` now match `setup.py` (GH-10289)
This could cause compile errors on macOS or other platforms.
files:
A Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
M Modules/Setup
diff --git a/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
new file mode 100644
index 000000000000..aa65088be809
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
@@ -0,0 +1 @@
+Fix a compiler error when statically linking `pyexpat` in `Modules/Setup`.
diff --git a/Modules/Setup b/Modules/Setup
index c1804630b903..e2b5f86f38e0 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -336,7 +336,7 @@ _symtable symtablemodule.c
# Interface to the Expat XML parser
# More information on Expat can be found at www.libexpat.org.
#
-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
+#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI
# Hye-Shik Chang's CJKCodecs
From webhook-mailer at python.org Thu Nov 1 23:09:08 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Fri, 02 Nov 2018 03:09:08 -0000
Subject: [Python-checkins] closes bpo-35139: The `pyexpat` module's macros
in `Modules/Setup` now match `setup.py` (GH-10289)
Message-ID:
https://github.com/python/cpython/commit/04c96669b161d802b7a906c06cd77895cee1864e
commit: 04c96669b161d802b7a906c06cd77895cee1864e
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T20:09:04-07:00
summary:
closes bpo-35139: The `pyexpat` module's macros in `Modules/Setup` now match `setup.py` (GH-10289)
This could cause compile errors on macOS or other platforms.
(cherry picked from commit 318ab63c01f5b8e7562b122ab5ba01258a51277b)
Co-authored-by: Max B?langer
files:
A Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
M Modules/Setup.dist
diff --git a/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
new file mode 100644
index 000000000000..aa65088be809
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
@@ -0,0 +1 @@
+Fix a compiler error when statically linking `pyexpat` in `Modules/Setup`.
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index f0eff5d2d0c2..8cc6bf0540d4 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -340,7 +340,7 @@ _symtable symtablemodule.c
# Interface to the Expat XML parser
# More information on Expat can be found at www.libexpat.org.
#
-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
+#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI
# Hye-Shik Chang's CJKCodecs
From webhook-mailer at python.org Thu Nov 1 23:28:39 2018
From: webhook-mailer at python.org (Benjamin Peterson)
Date: Fri, 02 Nov 2018 03:28:39 -0000
Subject: [Python-checkins] [2.7] closes bpo-35139: The `pyexpat` module's
macros in `Modules/Setup` now match `setup.py` (GH-10293)
Message-ID:
https://github.com/python/cpython/commit/a614cc92088c4e1b2d90aa03415ee6acf70f03b4
commit: a614cc92088c4e1b2d90aa03415ee6acf70f03b4
branch: 2.7
author: Benjamin Peterson
committer: GitHub
date: 2018-11-01T20:28:34-07:00
summary:
[2.7] closes bpo-35139: The `pyexpat` module's macros in `Modules/Setup` now match `setup.py` (GH-10293)
This could cause compile errors on macOS or other platforms..
(cherry picked from commit 318ab63c01f5b8e7562b122ab5ba01258a51277b)
Co-authored-by: Max B?langer
files:
A Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
M Modules/Setup.dist
diff --git a/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
new file mode 100644
index 000000000000..aa65088be809
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
@@ -0,0 +1 @@
+Fix a compiler error when statically linking `pyexpat` in `Modules/Setup`.
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index bd8b52e1de23..bbc922212964 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -469,7 +469,7 @@ GLHACK=-Dclear=__GLclear
# Interface to the Expat XML parser
# More information on Expat can be found at www.libexpat.org.
#
-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
+#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI
# Hye-Shik Chang's CJKCodecs
From webhook-mailer at python.org Thu Nov 1 23:29:43 2018
From: webhook-mailer at python.org (INADA Naoki)
Date: Fri, 02 Nov 2018 03:29:43 -0000
Subject: [Python-checkins] bpo-33578: Fix getstate/setstate for CJK decoder
(GH-10290)
Message-ID:
https://github.com/python/cpython/commit/488c0a6cdf09e21774e63c2a430ecc0de804d147
commit: 488c0a6cdf09e21774e63c2a430ecc0de804d147
branch: master
author: Christopher Thorne
committer: INADA Naoki
date: 2018-11-02T12:29:40+09:00
summary:
bpo-33578: Fix getstate/setstate for CJK decoder (GH-10290)
Previous version was casting to Py_ssize_t incorrectly
and exhibited unexpected behavior on big-endian systems.
files:
M Lib/test/test_multibytecodec.py
M Modules/cjkcodecs/multibytecodec.c
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 8e8362b70fd0..3cf5d7beb144 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -271,6 +271,10 @@ def test_state_methods(self):
pending4, _ = decoder.getstate()
self.assertEqual(pending4, b'')
+ # Ensure state values are preserved correctly
+ decoder.setstate((b'abc', 123456789))
+ self.assertEqual(decoder.getstate(), (b'abc', 123456789))
+
def test_setstate_validates_input(self):
decoder = codecs.getincrementaldecoder('euc_jp')()
self.assertRaises(TypeError, decoder.setstate, 123)
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 4633499a8abf..9409456c0d27 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -1218,6 +1218,7 @@ _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDe
/*[clinic end generated code: output=255009c4713b7f82 input=4006aa49bddbaa75]*/
{
PyObject *buffer;
+ PyObject *statelong;
buffer = PyBytes_FromStringAndSize((const char *)self->pending,
self->pendingsize);
@@ -1225,7 +1226,16 @@ _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDe
return NULL;
}
- return make_tuple(buffer, (Py_ssize_t)*self->state.c);
+ statelong = (PyObject *)_PyLong_FromByteArray(self->state.c,
+ sizeof(self->state.c),
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ );
+ if (statelong == NULL) {
+ Py_DECREF(buffer);
+ return NULL;
+ }
+
+ return Py_BuildValue("NN", buffer, statelong);
}
/*[clinic input]
@@ -1240,16 +1250,23 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDe
/*[clinic end generated code: output=106b2fbca3e2dcc2 input=e5d794e8baba1a47]*/
{
PyObject *buffer;
+ PyLongObject *statelong;
Py_ssize_t buffersize;
char *bufferstr;
- unsigned long long flag;
+ unsigned char statebytes[8];
- if (!PyArg_ParseTuple(state, "SK;setstate(): illegal state argument",
- &buffer, &flag))
+ if (!PyArg_ParseTuple(state, "SO!;setstate(): illegal state argument",
+ &buffer, &PyLong_Type, &statelong))
{
return NULL;
}
+ if (_PyLong_AsByteArray(statelong, statebytes, sizeof(statebytes),
+ 1 /* little-endian */ ,
+ 0 /* unsigned */ ) < 0) {
+ return NULL;
+ }
+
buffersize = PyBytes_Size(buffer);
if (buffersize == -1) {
return NULL;
@@ -1266,7 +1283,7 @@ _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDe
}
self->pendingsize = buffersize;
memcpy(self->pending, bufferstr, self->pendingsize);
- memcpy(self->state.c, (unsigned char *)&flag, sizeof(flag));
+ memcpy(self->state.c, statebytes, sizeof(statebytes));
Py_RETURN_NONE;
}
From webhook-mailer at python.org Thu Nov 1 23:32:34 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Fri, 02 Nov 2018 03:32:34 -0000
Subject: [Python-checkins] closes bpo-35139: The `pyexpat` module's macros
in `Modules/Setup` now match `setup.py` (GH-10289)
Message-ID:
https://github.com/python/cpython/commit/2339fe7cad9a84815fe551fedd6acdc3f2bf0a64
commit: 2339fe7cad9a84815fe551fedd6acdc3f2bf0a64
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-01T20:32:29-07:00
summary:
closes bpo-35139: The `pyexpat` module's macros in `Modules/Setup` now match `setup.py` (GH-10289)
This could cause compile errors on macOS or other platforms.
(cherry picked from commit 318ab63c01f5b8e7562b122ab5ba01258a51277b)
Co-authored-by: Max B?langer
files:
A Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
M Modules/Setup.dist
diff --git a/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
new file mode 100644
index 000000000000..aa65088be809
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2018-11-01-15-01-23.bpo-35139.XZTttb.rst
@@ -0,0 +1 @@
+Fix a compiler error when statically linking `pyexpat` in `Modules/Setup`.
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index acf4433cfe6f..e469d5e4c8e8 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -368,7 +368,7 @@ _symtable symtablemodule.c
# Interface to the Expat XML parser
# More information on Expat can be found at www.libexpat.org.
#
-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
+#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY=1 -DUSE_PYEXPAT_CAPI
# Hye-Shik Chang's CJKCodecs
From solipsis at pitrou.net Fri Nov 2 05:06:49 2018
From: solipsis at pitrou.net (solipsis at pitrou.net)
Date: Fri, 02 Nov 2018 09:06:49 +0000
Subject: [Python-checkins] Daily reference leaks (4243df51fe43): sum=4
Message-ID: <20181102090649.1.BD7A9EE865AB0972@psf.io>
results for 4243df51fe43 on branch "default"
--------------------------------------------
test_collections leaked [0, 7, -7] memory blocks, sum=0
test_functools leaked [0, 3, 1] memory blocks, sum=4
test_multiprocessing_forkserver leaked [1, -2, 2] memory blocks, sum=1
test_multiprocessing_spawn leaked [1, 0, -2] memory blocks, sum=-1
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogwp52G0', '--timeout', '7200']
From webhook-mailer at python.org Fri Nov 2 11:20:26 2018
From: webhook-mailer at python.org (Pablo Galindo)
Date: Fri, 02 Nov 2018 15:20:26 -0000
Subject: [Python-checkins] bpo-29341: Clarify that path-like objects are
accepted in some os methods (GH-10101)
Message-ID:
https://github.com/python/cpython/commit/b942707fc23454a998323c17e30be78ff1a4f0e7
commit: b942707fc23454a998323c17e30be78ff1a4f0e7
branch: master
author: BNMetrics
committer: Pablo Galindo
date: 2018-11-02T11:20:19-04:00
summary:
bpo-29341: Clarify that path-like objects are accepted in some os methods (GH-10101)
Some methods in the os module can accept path-like objects. This is documented in the general documentation but not in the function docstrings. To keep both in sync, the docstrings need to be updated to reflect that path-like objects are also accepted.
files:
A Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
M Modules/clinic/posixmodule.c.h
M Modules/posixmodule.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst b/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
new file mode 100644
index 000000000000..954ce8cbc09a
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
@@ -0,0 +1,2 @@
+Clarify in the docstrings of :mod:`os` methods that path-like objects are also accepted
+as input parameters.
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 99a1be70c12a..56010f408ccf 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -9,7 +9,7 @@ PyDoc_STRVAR(os_stat__doc__,
"Perform a stat system call on the given path.\n"
"\n"
" path\n"
-" Path to be examined; can be string, bytes, path-like object or\n"
+" Path to be examined; can be string, bytes, a path-like object or\n"
" open-file-descriptor int.\n"
" dir_fd\n"
" If not None, it should be a file descriptor open to a directory,\n"
@@ -101,7 +101,7 @@ PyDoc_STRVAR(os_access__doc__,
"Use the real uid/gid to test for access to a path.\n"
"\n"
" path\n"
-" Path to be tested; can be string or bytes\n"
+" Path to be tested; can be string, bytes, or a path-like object.\n"
" mode\n"
" Operating-system mode bitfield. Can be F_OK to test existence,\n"
" or the inclusive-OR of R_OK, W_OK, and X_OK.\n"
@@ -304,7 +304,7 @@ PyDoc_STRVAR(os_chmod__doc__,
"Change the access permissions of a file.\n"
"\n"
" path\n"
-" Path to be modified. May always be specified as a str or bytes.\n"
+" Path to be modified. May always be specified as a str, bytes, or a path-like object.\n"
" On some platforms, path may also be specified as an open file descriptor.\n"
" If this functionality is unavailable, using it raises an exception.\n"
" mode\n"
@@ -655,7 +655,7 @@ PyDoc_STRVAR(os_chown__doc__,
"Change the owner and group id of path to the numeric uid and gid.\\\n"
"\n"
" path\n"
-" Path to be examined; can be string, bytes, or open-file-descriptor int.\n"
+" Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.\n"
" dir_fd\n"
" If not None, it should be a file descriptor open to a directory,\n"
" and path should be relative; path will then be relative to that\n"
@@ -889,7 +889,7 @@ PyDoc_STRVAR(os_listdir__doc__,
"\n"
"Return a list containing the names of the files in the directory.\n"
"\n"
-"path can be specified as either str or bytes. If path is bytes,\n"
+"path can be specified as either str, bytes, or a path-like object. If path is bytes,\n"
" the filenames returned will also be bytes; in all other circumstances\n"
" the filenames returned will be str.\n"
"If path is None, uses the path=\'.\'.\n"
@@ -5532,7 +5532,7 @@ PyDoc_STRVAR(os_getxattr__doc__,
"\n"
"Return the value of extended attribute attribute on path.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, getxattr will examine the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5580,7 +5580,7 @@ PyDoc_STRVAR(os_setxattr__doc__,
"\n"
"Set extended attribute attribute on path to value.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, setxattr will modify the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5633,7 +5633,7 @@ PyDoc_STRVAR(os_removexattr__doc__,
"\n"
"Remove extended attribute attribute on path.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, removexattr will modify the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5680,7 +5680,7 @@ PyDoc_STRVAR(os_listxattr__doc__,
"\n"
"Return a list of extended attributes on path.\n"
"\n"
-"path may be either None, a string, or an open file descriptor.\n"
+"path may be either None, a string, a path-like object, or an open file descriptor.\n"
"if path is None, listxattr will examine the current directory.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, listxattr will examine the symbolic link itself instead of the file\n"
@@ -6140,7 +6140,7 @@ PyDoc_STRVAR(os_scandir__doc__,
"\n"
"Return an iterator of DirEntry objects for given path.\n"
"\n"
-"path can be specified as either str, bytes or path-like object. If path\n"
+"path can be specified as either str, bytes, or a path-like object. If path\n"
"is bytes, the names of yielded DirEntry objects will also be bytes; in\n"
"all other circumstances they will be str.\n"
"\n"
@@ -6757,4 +6757,4 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
-/*[clinic end generated code: output=1603fddefffa1fb9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f2951c34e0907fb6 input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0307436e3d59..bf886e31d762 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2480,7 +2480,7 @@ class sched_param_converter(CConverter):
os.stat
path : path_t(allow_fd=True)
- Path to be examined; can be string, bytes, path-like object or
+ Path to be examined; can be string, bytes, a path-like object or
open-file-descriptor int.
*
@@ -2508,7 +2508,7 @@ It's an error to use dir_fd or follow_symlinks when specifying path as
static PyObject *
os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks)
-/*[clinic end generated code: output=7d4976e6f18a59c5 input=270bd64e7bb3c8f7]*/
+/*[clinic end generated code: output=7d4976e6f18a59c5 input=01d362ebcc06996b]*/
{
return posix_do_stat("stat", path, dir_fd, follow_symlinks);
}
@@ -2542,7 +2542,7 @@ os_lstat_impl(PyObject *module, path_t *path, int dir_fd)
os.access -> bool
path: path_t
- Path to be tested; can be string or bytes
+ Path to be tested; can be string, bytes, or a path-like object.
mode: int
Operating-system mode bitfield. Can be F_OK to test existence,
@@ -2580,7 +2580,7 @@ Note that most operations will use the effective uid/gid, therefore this
static int
os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int effective_ids, int follow_symlinks)
-/*[clinic end generated code: output=cf84158bc90b1a77 input=8e8c3a6ba791fee3]*/
+/*[clinic end generated code: output=cf84158bc90b1a77 input=3ffe4e650ee3bf20]*/
{
int return_value;
@@ -2772,7 +2772,7 @@ os_fchdir_impl(PyObject *module, int fd)
os.chmod
path: path_t(allow_fd='PATH_HAVE_FCHMOD')
- Path to be modified. May always be specified as a str or bytes.
+ Path to be modified. May always be specified as a str, bytes, or a path-like object.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
@@ -2803,7 +2803,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int follow_symlinks)
-/*[clinic end generated code: output=5cf6a94915cc7bff input=7f1618e5e15cc196]*/
+/*[clinic end generated code: output=5cf6a94915cc7bff input=989081551c00293b]*/
{
int result;
@@ -3123,7 +3123,7 @@ os_fdatasync_impl(PyObject *module, int fd)
os.chown
path : path_t(allow_fd='PATH_HAVE_FCHOWN')
- Path to be examined; can be string, bytes, or open-file-descriptor int.
+ Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.
uid: uid_t
@@ -3161,7 +3161,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
int dir_fd, int follow_symlinks)
-/*[clinic end generated code: output=4beadab0db5f70cd input=a61cc35574814d5d]*/
+/*[clinic end generated code: output=4beadab0db5f70cd input=b08c5ec67996a97d]*/
{
int result;
@@ -3688,7 +3688,7 @@ os.listdir
Return a list containing the names of the files in the directory.
-path can be specified as either str or bytes. If path is bytes,
+path can be specified as either str, bytes, or a path-like object. If path is bytes,
the filenames returned will also be bytes; in all other circumstances
the filenames returned will be str.
If path is None, uses the path='.'.
@@ -3704,7 +3704,7 @@ entries '.' and '..' even if they are present in the directory.
static PyObject *
os_listdir_impl(PyObject *module, path_t *path)
-/*[clinic end generated code: output=293045673fcd1a75 input=09e300416e3cd729]*/
+/*[clinic end generated code: output=293045673fcd1a75 input=e3f58030f538295d]*/
{
#if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR)
return _listdir_windows_no_opendir(path, NULL);
@@ -11415,7 +11415,7 @@ os.getxattr
Return the value of extended attribute attribute on path.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, getxattr will examine the symbolic link itself instead of the file
the link points to.
@@ -11425,7 +11425,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute,
int follow_symlinks)
-/*[clinic end generated code: output=5f2f44200a43cff2 input=8c8ea3bab78d89c2]*/
+/*[clinic end generated code: output=5f2f44200a43cff2 input=025789491708f7eb]*/
{
Py_ssize_t i;
PyObject *buffer = NULL;
@@ -11487,7 +11487,7 @@ os.setxattr
Set extended attribute attribute on path to value.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, setxattr will modify the symbolic link itself instead of the file
the link points to.
@@ -11497,7 +11497,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute,
Py_buffer *value, int flags, int follow_symlinks)
-/*[clinic end generated code: output=98b83f63fdde26bb input=f0d26833992015c2]*/
+/*[clinic end generated code: output=98b83f63fdde26bb input=c17c0103009042f0]*/
{
ssize_t result;
@@ -11535,7 +11535,7 @@ os.removexattr
Remove extended attribute attribute on path.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, removexattr will modify the symbolic link itself instead of the file
the link points to.
@@ -11545,7 +11545,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute,
int follow_symlinks)
-/*[clinic end generated code: output=521a51817980cda6 input=cdb54834161e3329]*/
+/*[clinic end generated code: output=521a51817980cda6 input=3d9a7d36fe2f7c4e]*/
{
ssize_t result;
@@ -11578,7 +11578,7 @@ os.listxattr
Return a list of extended attributes on path.
-path may be either None, a string, or an open file descriptor.
+path may be either None, a string, a path-like object, or an open file descriptor.
if path is None, listxattr will examine the current directory.
If follow_symlinks is False, and the last element of the path is a symbolic
link, listxattr will examine the symbolic link itself instead of the file
@@ -11587,7 +11587,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
-/*[clinic end generated code: output=bebdb4e2ad0ce435 input=08cca53ac0b07c13]*/
+/*[clinic end generated code: output=bebdb4e2ad0ce435 input=9826edf9fdb90869]*/
{
Py_ssize_t i;
PyObject *result = NULL;
@@ -12836,7 +12836,7 @@ os.scandir
Return an iterator of DirEntry objects for given path.
-path can be specified as either str, bytes or path-like object. If path
+path can be specified as either str, bytes, or a path-like object. If path
is bytes, the names of yielded DirEntry objects will also be bytes; in
all other circumstances they will be str.
@@ -12845,7 +12845,7 @@ If path is None, uses the path='.'.
static PyObject *
os_scandir_impl(PyObject *module, path_t *path)
-/*[clinic end generated code: output=6eb2668b675ca89e input=b139dc1c57f60846]*/
+/*[clinic end generated code: output=6eb2668b675ca89e input=6bdd312708fc3bb0]*/
{
ScandirIterator *iterator;
#ifdef MS_WINDOWS
From webhook-mailer at python.org Fri Nov 2 12:32:31 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Fri, 02 Nov 2018 16:32:31 -0000
Subject: [Python-checkins] bpo-35147: Fix _Py_NO_RETURN for GCC (GH-10300)
Message-ID:
https://github.com/python/cpython/commit/e2ed5adcb5db2d70cfa72da1ba8446f7aa9e05cd
commit: e2ed5adcb5db2d70cfa72da1ba8446f7aa9e05cd
branch: master
author: Alexey Izbyshev
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-11-02T09:32:26-07:00
summary:
bpo-35147: Fix _Py_NO_RETURN for GCC (GH-10300)
Use `__GNUC__` instead of non-existing `__GNUC_MAJOR__`.
https://bugs.python.org/issue35147
files:
M Include/pyerrors.h
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 4e2995469f3c..808e0def06b4 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -94,9 +94,9 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
#endif
#if defined(__clang__) || \
- (defined(__GNUC_MAJOR__) && \
- ((__GNUC_MAJOR__ >= 3) || \
- (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
+ (defined(__GNUC__) && \
+ ((__GNUC__ >= 3) || \
+ (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
# define _Py_NO_RETURN __attribute__((__noreturn__))
#elif defined(_MSC_VER)
# define _Py_NO_RETURN __declspec(noreturn)
From webhook-mailer at python.org Fri Nov 2 13:55:46 2018
From: webhook-mailer at python.org (Pablo Galindo)
Date: Fri, 02 Nov 2018 17:55:46 -0000
Subject: [Python-checkins] [3.6]bpo-29341: Backport b942707 3.6 (GH-10299)
Message-ID:
https://github.com/python/cpython/commit/8d2f88fb17468642813108977bb9ec5f7a065b84
commit: 8d2f88fb17468642813108977bb9ec5f7a065b84
branch: 3.6
author: BNMetrics
committer: Pablo Galindo
date: 2018-11-02T13:55:31-04:00
summary:
[3.6]bpo-29341: Backport b942707 3.6 (GH-10299)
Some methods in the os module can accept path-like objects. This is documented in the general documentation but not in the function docstrings. To keep both in sync, the docstrings need to be updated to reflect that path-like objects are also accepted..
(cherry picked from commit b942707fc23454a998323c17e30be78ff1a4f0e7)
Co-authored-by: BNMetrics
files:
A Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
M Modules/clinic/posixmodule.c.h
M Modules/posixmodule.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst b/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
new file mode 100644
index 000000000000..954ce8cbc09a
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
@@ -0,0 +1,2 @@
+Clarify in the docstrings of :mod:`os` methods that path-like objects are also accepted
+as input parameters.
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 0d3ce6eed65d..e615e00b33c1 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -9,7 +9,7 @@ PyDoc_STRVAR(os_stat__doc__,
"Perform a stat system call on the given path.\n"
"\n"
" path\n"
-" Path to be examined; can be string, bytes, path-like object or\n"
+" Path to be examined; can be string, bytes, a path-like object or\n"
" open-file-descriptor int.\n"
" dir_fd\n"
" If not None, it should be a file descriptor open to a directory,\n"
@@ -101,7 +101,7 @@ PyDoc_STRVAR(os_access__doc__,
"Use the real uid/gid to test for access to a path.\n"
"\n"
" path\n"
-" Path to be tested; can be string or bytes\n"
+" Path to be tested; can be string, bytes, or a path-like object.\n"
" mode\n"
" Operating-system mode bitfield. Can be F_OK to test existence,\n"
" or the inclusive-OR of R_OK, W_OK, and X_OK.\n"
@@ -304,7 +304,7 @@ PyDoc_STRVAR(os_chmod__doc__,
"Change the access permissions of a file.\n"
"\n"
" path\n"
-" Path to be modified. May always be specified as a str or bytes.\n"
+" Path to be modified. May always be specified as a str, bytes, or a path-like object.\n"
" On some platforms, path may also be specified as an open file descriptor.\n"
" If this functionality is unavailable, using it raises an exception.\n"
" mode\n"
@@ -655,7 +655,7 @@ PyDoc_STRVAR(os_chown__doc__,
"Change the owner and group id of path to the numeric uid and gid.\\\n"
"\n"
" path\n"
-" Path to be examined; can be string, bytes, or open-file-descriptor int.\n"
+" Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.\n"
" dir_fd\n"
" If not None, it should be a file descriptor open to a directory,\n"
" and path should be relative; path will then be relative to that\n"
@@ -889,7 +889,7 @@ PyDoc_STRVAR(os_listdir__doc__,
"\n"
"Return a list containing the names of the files in the directory.\n"
"\n"
-"path can be specified as either str or bytes. If path is bytes,\n"
+"path can be specified as either str, bytes, or a path-like object. If path is bytes,\n"
" the filenames returned will also be bytes; in all other circumstances\n"
" the filenames returned will be str.\n"
"If path is None, uses the path=\'.\'.\n"
@@ -5234,7 +5234,7 @@ PyDoc_STRVAR(os_getxattr__doc__,
"\n"
"Return the value of extended attribute attribute on path.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, getxattr will examine the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5282,7 +5282,7 @@ PyDoc_STRVAR(os_setxattr__doc__,
"\n"
"Set extended attribute attribute on path to value.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, setxattr will modify the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5335,7 +5335,7 @@ PyDoc_STRVAR(os_removexattr__doc__,
"\n"
"Remove extended attribute attribute on path.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, removexattr will modify the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5382,7 +5382,7 @@ PyDoc_STRVAR(os_listxattr__doc__,
"\n"
"Return a list of extended attributes on path.\n"
"\n"
-"path may be either None, a string, or an open file descriptor.\n"
+"path may be either None, a string, a path-like object, or an open file descriptor.\n"
"if path is None, listxattr will examine the current directory.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, listxattr will examine the symbolic link itself instead of the file\n"
@@ -6150,4 +6150,4 @@ os_getrandom(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwna
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
-/*[clinic end generated code: output=455def991740915a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=92026f29ec925950 input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 7358c393b1a0..f5642d267299 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2391,7 +2391,7 @@ class sched_param_converter(CConverter):
os.stat
path : path_t(allow_fd=True)
- Path to be examined; can be string, bytes, path-like object or
+ Path to be examined; can be string, bytes, a path-like object or
open-file-descriptor int.
*
@@ -2419,7 +2419,7 @@ It's an error to use dir_fd or follow_symlinks when specifying path as
static PyObject *
os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks)
-/*[clinic end generated code: output=7d4976e6f18a59c5 input=270bd64e7bb3c8f7]*/
+/*[clinic end generated code: output=7d4976e6f18a59c5 input=01d362ebcc06996b]*/
{
return posix_do_stat("stat", path, dir_fd, follow_symlinks);
}
@@ -2453,7 +2453,7 @@ os_lstat_impl(PyObject *module, path_t *path, int dir_fd)
os.access -> bool
path: path_t
- Path to be tested; can be string or bytes
+ Path to be tested; can be string, bytes, or a path-like object.
mode: int
Operating-system mode bitfield. Can be F_OK to test existence,
@@ -2491,7 +2491,7 @@ Note that most operations will use the effective uid/gid, therefore this
static int
os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int effective_ids, int follow_symlinks)
-/*[clinic end generated code: output=cf84158bc90b1a77 input=8e8c3a6ba791fee3]*/
+/*[clinic end generated code: output=cf84158bc90b1a77 input=3ffe4e650ee3bf20]*/
{
int return_value;
@@ -2683,7 +2683,7 @@ os_fchdir_impl(PyObject *module, int fd)
os.chmod
path: path_t(allow_fd='PATH_HAVE_FCHMOD')
- Path to be modified. May always be specified as a str or bytes.
+ Path to be modified. May always be specified as a str, bytes, or a path-like object.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
@@ -2714,7 +2714,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int follow_symlinks)
-/*[clinic end generated code: output=5cf6a94915cc7bff input=7f1618e5e15cc196]*/
+/*[clinic end generated code: output=5cf6a94915cc7bff input=989081551c00293b]*/
{
int result;
@@ -3034,7 +3034,7 @@ os_fdatasync_impl(PyObject *module, int fd)
os.chown
path : path_t(allow_fd='PATH_HAVE_FCHOWN')
- Path to be examined; can be string, bytes, or open-file-descriptor int.
+ Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.
uid: uid_t
@@ -3072,7 +3072,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
int dir_fd, int follow_symlinks)
-/*[clinic end generated code: output=4beadab0db5f70cd input=a61cc35574814d5d]*/
+/*[clinic end generated code: output=4beadab0db5f70cd input=b08c5ec67996a97d]*/
{
int result;
@@ -3599,7 +3599,7 @@ os.listdir
Return a list containing the names of the files in the directory.
-path can be specified as either str or bytes. If path is bytes,
+path can be specified as either str, bytes, or a path-like object. If path is bytes,
the filenames returned will also be bytes; in all other circumstances
the filenames returned will be str.
If path is None, uses the path='.'.
@@ -3615,7 +3615,7 @@ entries '.' and '..' even if they are present in the directory.
static PyObject *
os_listdir_impl(PyObject *module, path_t *path)
-/*[clinic end generated code: output=293045673fcd1a75 input=09e300416e3cd729]*/
+/*[clinic end generated code: output=293045673fcd1a75 input=e3f58030f538295d]*/
{
#if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR)
return _listdir_windows_no_opendir(path, NULL);
@@ -10667,7 +10667,7 @@ os.getxattr
Return the value of extended attribute attribute on path.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, getxattr will examine the symbolic link itself instead of the file
the link points to.
@@ -10677,7 +10677,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute,
int follow_symlinks)
-/*[clinic end generated code: output=5f2f44200a43cff2 input=8c8ea3bab78d89c2]*/
+/*[clinic end generated code: output=5f2f44200a43cff2 input=025789491708f7eb]*/
{
Py_ssize_t i;
PyObject *buffer = NULL;
@@ -10739,7 +10739,7 @@ os.setxattr
Set extended attribute attribute on path to value.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, setxattr will modify the symbolic link itself instead of the file
the link points to.
@@ -10749,7 +10749,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute,
Py_buffer *value, int flags, int follow_symlinks)
-/*[clinic end generated code: output=98b83f63fdde26bb input=f0d26833992015c2]*/
+/*[clinic end generated code: output=98b83f63fdde26bb input=c17c0103009042f0]*/
{
ssize_t result;
@@ -10787,7 +10787,7 @@ os.removexattr
Remove extended attribute attribute on path.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, removexattr will modify the symbolic link itself instead of the file
the link points to.
@@ -10797,7 +10797,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute,
int follow_symlinks)
-/*[clinic end generated code: output=521a51817980cda6 input=cdb54834161e3329]*/
+/*[clinic end generated code: output=521a51817980cda6 input=3d9a7d36fe2f7c4e]*/
{
ssize_t result;
@@ -10830,7 +10830,7 @@ os.listxattr
Return a list of extended attributes on path.
-path may be either None, a string, or an open file descriptor.
+path may be either None, a string, a path-like object, or an open file descriptor.
if path is None, listxattr will examine the current directory.
If follow_symlinks is False, and the last element of the path is a symbolic
link, listxattr will examine the symbolic link itself instead of the file
@@ -10839,7 +10839,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
-/*[clinic end generated code: output=bebdb4e2ad0ce435 input=08cca53ac0b07c13]*/
+/*[clinic end generated code: output=bebdb4e2ad0ce435 input=9826edf9fdb90869]*/
{
Py_ssize_t i;
PyObject *result = NULL;
From webhook-mailer at python.org Fri Nov 2 13:56:29 2018
From: webhook-mailer at python.org (Pablo Galindo)
Date: Fri, 02 Nov 2018 17:56:29 -0000
Subject: [Python-checkins] [3.7]bpo-29341: Backport b942707 3.7 (#10298)
Message-ID:
https://github.com/python/cpython/commit/08026b103ea8f4c9f2b5045ef7806dd8b760da2b
commit: 08026b103ea8f4c9f2b5045ef7806dd8b760da2b
branch: 3.7
author: BNMetrics
committer: Pablo Galindo
date: 2018-11-02T13:56:25-04:00
summary:
[3.7]bpo-29341: Backport b942707 3.7 (#10298)
Some methods in the os module can accept path-like objects. This is documented in the general documentation but not in the function docstrings. To keep both in sync, the docstrings need to be updated to reflect that path-like objects are also accepted..
(cherry picked from commit b942707fc23454a998323c17e30be78ff1a4f0e7)
Co-authored-by: BNMetrics
files:
A Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
M Modules/clinic/posixmodule.c.h
M Modules/posixmodule.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst b/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
new file mode 100644
index 000000000000..954ce8cbc09a
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-10-25-20-53-32.bpo-29341.jH-AMF.rst
@@ -0,0 +1,2 @@
+Clarify in the docstrings of :mod:`os` methods that path-like objects are also accepted
+as input parameters.
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index ab1f75350340..3230cd700972 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -9,7 +9,7 @@ PyDoc_STRVAR(os_stat__doc__,
"Perform a stat system call on the given path.\n"
"\n"
" path\n"
-" Path to be examined; can be string, bytes, path-like object or\n"
+" Path to be examined; can be string, bytes, a path-like object or\n"
" open-file-descriptor int.\n"
" dir_fd\n"
" If not None, it should be a file descriptor open to a directory,\n"
@@ -101,7 +101,7 @@ PyDoc_STRVAR(os_access__doc__,
"Use the real uid/gid to test for access to a path.\n"
"\n"
" path\n"
-" Path to be tested; can be string or bytes\n"
+" Path to be tested; can be string, bytes, or a path-like object.\n"
" mode\n"
" Operating-system mode bitfield. Can be F_OK to test existence,\n"
" or the inclusive-OR of R_OK, W_OK, and X_OK.\n"
@@ -304,7 +304,7 @@ PyDoc_STRVAR(os_chmod__doc__,
"Change the access permissions of a file.\n"
"\n"
" path\n"
-" Path to be modified. May always be specified as a str or bytes.\n"
+" Path to be modified. May always be specified as a str, bytes, or a path-like object.\n"
" On some platforms, path may also be specified as an open file descriptor.\n"
" If this functionality is unavailable, using it raises an exception.\n"
" mode\n"
@@ -655,7 +655,7 @@ PyDoc_STRVAR(os_chown__doc__,
"Change the owner and group id of path to the numeric uid and gid.\\\n"
"\n"
" path\n"
-" Path to be examined; can be string, bytes, or open-file-descriptor int.\n"
+" Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.\n"
" dir_fd\n"
" If not None, it should be a file descriptor open to a directory,\n"
" and path should be relative; path will then be relative to that\n"
@@ -889,7 +889,7 @@ PyDoc_STRVAR(os_listdir__doc__,
"\n"
"Return a list containing the names of the files in the directory.\n"
"\n"
-"path can be specified as either str or bytes. If path is bytes,\n"
+"path can be specified as either str, bytes, or a path-like object. If path is bytes,\n"
" the filenames returned will also be bytes; in all other circumstances\n"
" the filenames returned will be str.\n"
"If path is None, uses the path=\'.\'.\n"
@@ -5406,7 +5406,7 @@ PyDoc_STRVAR(os_getxattr__doc__,
"\n"
"Return the value of extended attribute attribute on path.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, getxattr will examine the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5454,7 +5454,7 @@ PyDoc_STRVAR(os_setxattr__doc__,
"\n"
"Set extended attribute attribute on path to value.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, setxattr will modify the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5507,7 +5507,7 @@ PyDoc_STRVAR(os_removexattr__doc__,
"\n"
"Remove extended attribute attribute on path.\n"
"\n"
-"path may be either a string or an open file descriptor.\n"
+"path may be either a string, a path-like object, or an open file descriptor.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, removexattr will modify the symbolic link itself instead of the file\n"
" the link points to.");
@@ -5554,7 +5554,7 @@ PyDoc_STRVAR(os_listxattr__doc__,
"\n"
"Return a list of extended attributes on path.\n"
"\n"
-"path may be either None, a string, or an open file descriptor.\n"
+"path may be either None, a string, a path-like object, or an open file descriptor.\n"
"if path is None, listxattr will examine the current directory.\n"
"If follow_symlinks is False, and the last element of the path is a symbolic\n"
" link, listxattr will examine the symbolic link itself instead of the file\n"
@@ -5940,7 +5940,7 @@ PyDoc_STRVAR(os_scandir__doc__,
"\n"
"Return an iterator of DirEntry objects for given path.\n"
"\n"
-"path can be specified as either str, bytes or path-like object. If path\n"
+"path can be specified as either str, bytes, or a path-like object. If path\n"
"is bytes, the names of yielded DirEntry objects will also be bytes; in\n"
"all other circumstances they will be str.\n"
"\n"
@@ -6537,4 +6537,4 @@ os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
-/*[clinic end generated code: output=c966c821d557b7c0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c6ca6ad4afa64454 input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0c48a66a64dd..8ff487d8cc1f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2446,7 +2446,7 @@ class sched_param_converter(CConverter):
os.stat
path : path_t(allow_fd=True)
- Path to be examined; can be string, bytes, path-like object or
+ Path to be examined; can be string, bytes, a path-like object or
open-file-descriptor int.
*
@@ -2474,7 +2474,7 @@ It's an error to use dir_fd or follow_symlinks when specifying path as
static PyObject *
os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks)
-/*[clinic end generated code: output=7d4976e6f18a59c5 input=270bd64e7bb3c8f7]*/
+/*[clinic end generated code: output=7d4976e6f18a59c5 input=01d362ebcc06996b]*/
{
return posix_do_stat("stat", path, dir_fd, follow_symlinks);
}
@@ -2508,7 +2508,7 @@ os_lstat_impl(PyObject *module, path_t *path, int dir_fd)
os.access -> bool
path: path_t
- Path to be tested; can be string or bytes
+ Path to be tested; can be string, bytes, or a path-like object.
mode: int
Operating-system mode bitfield. Can be F_OK to test existence,
@@ -2546,7 +2546,7 @@ Note that most operations will use the effective uid/gid, therefore this
static int
os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int effective_ids, int follow_symlinks)
-/*[clinic end generated code: output=cf84158bc90b1a77 input=8e8c3a6ba791fee3]*/
+/*[clinic end generated code: output=cf84158bc90b1a77 input=3ffe4e650ee3bf20]*/
{
int return_value;
@@ -2738,7 +2738,7 @@ os_fchdir_impl(PyObject *module, int fd)
os.chmod
path: path_t(allow_fd='PATH_HAVE_FCHMOD')
- Path to be modified. May always be specified as a str or bytes.
+ Path to be modified. May always be specified as a str, bytes, or a path-like object.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
@@ -2769,7 +2769,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int follow_symlinks)
-/*[clinic end generated code: output=5cf6a94915cc7bff input=7f1618e5e15cc196]*/
+/*[clinic end generated code: output=5cf6a94915cc7bff input=989081551c00293b]*/
{
int result;
@@ -3089,7 +3089,7 @@ os_fdatasync_impl(PyObject *module, int fd)
os.chown
path : path_t(allow_fd='PATH_HAVE_FCHOWN')
- Path to be examined; can be string, bytes, or open-file-descriptor int.
+ Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.
uid: uid_t
@@ -3127,7 +3127,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
int dir_fd, int follow_symlinks)
-/*[clinic end generated code: output=4beadab0db5f70cd input=a61cc35574814d5d]*/
+/*[clinic end generated code: output=4beadab0db5f70cd input=b08c5ec67996a97d]*/
{
int result;
@@ -3654,7 +3654,7 @@ os.listdir
Return a list containing the names of the files in the directory.
-path can be specified as either str or bytes. If path is bytes,
+path can be specified as either str, bytes, or a path-like object. If path is bytes,
the filenames returned will also be bytes; in all other circumstances
the filenames returned will be str.
If path is None, uses the path='.'.
@@ -3670,7 +3670,7 @@ entries '.' and '..' even if they are present in the directory.
static PyObject *
os_listdir_impl(PyObject *module, path_t *path)
-/*[clinic end generated code: output=293045673fcd1a75 input=09e300416e3cd729]*/
+/*[clinic end generated code: output=293045673fcd1a75 input=e3f58030f538295d]*/
{
#if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR)
return _listdir_windows_no_opendir(path, NULL);
@@ -10973,7 +10973,7 @@ os.getxattr
Return the value of extended attribute attribute on path.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, getxattr will examine the symbolic link itself instead of the file
the link points to.
@@ -10983,7 +10983,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute,
int follow_symlinks)
-/*[clinic end generated code: output=5f2f44200a43cff2 input=8c8ea3bab78d89c2]*/
+/*[clinic end generated code: output=5f2f44200a43cff2 input=025789491708f7eb]*/
{
Py_ssize_t i;
PyObject *buffer = NULL;
@@ -11045,7 +11045,7 @@ os.setxattr
Set extended attribute attribute on path to value.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, setxattr will modify the symbolic link itself instead of the file
the link points to.
@@ -11055,7 +11055,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute,
Py_buffer *value, int flags, int follow_symlinks)
-/*[clinic end generated code: output=98b83f63fdde26bb input=f0d26833992015c2]*/
+/*[clinic end generated code: output=98b83f63fdde26bb input=c17c0103009042f0]*/
{
ssize_t result;
@@ -11093,7 +11093,7 @@ os.removexattr
Remove extended attribute attribute on path.
-path may be either a string or an open file descriptor.
+path may be either a string, a path-like object, or an open file descriptor.
If follow_symlinks is False, and the last element of the path is a symbolic
link, removexattr will modify the symbolic link itself instead of the file
the link points to.
@@ -11103,7 +11103,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute,
int follow_symlinks)
-/*[clinic end generated code: output=521a51817980cda6 input=cdb54834161e3329]*/
+/*[clinic end generated code: output=521a51817980cda6 input=3d9a7d36fe2f7c4e]*/
{
ssize_t result;
@@ -11136,7 +11136,7 @@ os.listxattr
Return a list of extended attributes on path.
-path may be either None, a string, or an open file descriptor.
+path may be either None, a string, a path-like object, or an open file descriptor.
if path is None, listxattr will examine the current directory.
If follow_symlinks is False, and the last element of the path is a symbolic
link, listxattr will examine the symbolic link itself instead of the file
@@ -11145,7 +11145,7 @@ If follow_symlinks is False, and the last element of the path is a symbolic
static PyObject *
os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
-/*[clinic end generated code: output=bebdb4e2ad0ce435 input=08cca53ac0b07c13]*/
+/*[clinic end generated code: output=bebdb4e2ad0ce435 input=9826edf9fdb90869]*/
{
Py_ssize_t i;
PyObject *result = NULL;
@@ -12392,7 +12392,7 @@ os.scandir
Return an iterator of DirEntry objects for given path.
-path can be specified as either str, bytes or path-like object. If path
+path can be specified as either str, bytes, or a path-like object. If path
is bytes, the names of yielded DirEntry objects will also be bytes; in
all other circumstances they will be str.
@@ -12401,7 +12401,7 @@ If path is None, uses the path='.'.
static PyObject *
os_scandir_impl(PyObject *module, path_t *path)
-/*[clinic end generated code: output=6eb2668b675ca89e input=b139dc1c57f60846]*/
+/*[clinic end generated code: output=6eb2668b675ca89e input=6bdd312708fc3bb0]*/
{
ScandirIterator *iterator;
#ifdef MS_WINDOWS
From webhook-mailer at python.org Fri Nov 2 14:23:59 2018
From: webhook-mailer at python.org (Victor Stinner)
Date: Fri, 02 Nov 2018 18:23:59 -0000
Subject: [Python-checkins] [3.6] bpo-35147: Fix _Py_NO_RETURN for GCC
(GH-10300) (GH-10302)
Message-ID:
https://github.com/python/cpython/commit/29abad099535f4bcb1531df93bafbd75b26d6adc
commit: 29abad099535f4bcb1531df93bafbd75b26d6adc
branch: 3.6
author: Alexey Izbyshev
committer: Victor Stinner
date: 2018-11-02T19:23:51+01:00
summary:
[3.6] bpo-35147: Fix _Py_NO_RETURN for GCC (GH-10300) (GH-10302)
Use `__GNUC__` instead of non-existing `__GNUC_MAJOR__`.
(cherry picked from commit e2ed5adcb5db2d70cfa72da1ba8446f7aa9e05cd)
files:
M Include/pyerrors.h
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index c28c1373f82f..44f20303c299 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -93,9 +93,9 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
#endif
#if defined(__clang__) || \
- (defined(__GNUC_MAJOR__) && \
- ((__GNUC_MAJOR__ >= 3) || \
- (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
+ (defined(__GNUC__) && \
+ ((__GNUC__ >= 3) || \
+ (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
#define _Py_NO_RETURN __attribute__((__noreturn__))
#else
#define _Py_NO_RETURN
From webhook-mailer at python.org Fri Nov 2 21:30:16 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Sat, 03 Nov 2018 01:30:16 -0000
Subject: [Python-checkins] [3.7] bpo-35147: Fix _Py_NO_RETURN for GCC
(GH-10300) (GH-10301)
Message-ID:
https://github.com/python/cpython/commit/a9122d183b1fbc4484d72aec69fc0979c7fd91f2
commit: a9122d183b1fbc4484d72aec69fc0979c7fd91f2
branch: 3.7
author: Alexey Izbyshev
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-11-02T18:30:11-07:00
summary:
[3.7] bpo-35147: Fix _Py_NO_RETURN for GCC (GH-10300) (GH-10301)
Use `__GNUC__` instead of non-existing `__GNUC_MAJOR__`.
(cherry picked from commit e2ed5adcb5db2d70cfa72da1ba8446f7aa9e05cd)
https://bugs.python.org/issue35147
files:
M Include/pyerrors.h
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index f289471be20c..f49d4e8bd08c 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -94,9 +94,9 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
#endif
#if defined(__clang__) || \
- (defined(__GNUC_MAJOR__) && \
- ((__GNUC_MAJOR__ >= 3) || \
- (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5)))
+ (defined(__GNUC__) && \
+ ((__GNUC__ >= 3) || \
+ (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
#define _Py_NO_RETURN __attribute__((__noreturn__))
#else
#define _Py_NO_RETURN
From solipsis at pitrou.net Sat Nov 3 05:09:19 2018
From: solipsis at pitrou.net (solipsis at pitrou.net)
Date: Sat, 03 Nov 2018 09:09:19 +0000
Subject: [Python-checkins] Daily reference leaks (4243df51fe43): sum=12
Message-ID: <20181103090919.1.527F4B46337036B8@psf.io>
results for 4243df51fe43 on branch "default"
--------------------------------------------
test_collections leaked [7, -7, 8] memory blocks, sum=8
test_functools leaked [0, 3, 1] memory blocks, sum=4
test_multiprocessing_forkserver leaked [-1, 2, -1] memory blocks, sum=0
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogcl6rDp', '--timeout', '7200']
From webhook-mailer at python.org Sat Nov 3 11:06:04 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Sat, 03 Nov 2018 15:06:04 -0000
Subject: [Python-checkins] Fix a typo about a comma. (GH-10306)
Message-ID:
https://github.com/python/cpython/commit/fe62d877e300e1ee4145fff8f2bdba498b685f91
commit: fe62d877e300e1ee4145fff8f2bdba498b685f91
branch: master
author: ?smail Ar?l?k
committer: Serhiy Storchaka
date: 2018-11-03T17:05:59+02:00
summary:
Fix a typo about a comma. (GH-10306)
files:
M Doc/tutorial/errors.rst
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index aba61da5f7c3..957cbf962b20 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -314,7 +314,7 @@ to create specific exception classes for different error conditions::
self.next = next
self.message = message
-Most exceptions are defined with names that end in "Error," similar to the
+Most exceptions are defined with names that end in "Error", similar to the
naming of the standard exceptions.
Many standard modules define their own exceptions to report errors that may
From webhook-mailer at python.org Sat Nov 3 11:24:27 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sat, 03 Nov 2018 15:24:27 -0000
Subject: [Python-checkins] bpo-34969: Add --fast,
--best on the gzip CLI (GH-9833)
Message-ID:
https://github.com/python/cpython/commit/3e28eed9ec2249bb11ad0db4629271b7ce9b7918
commit: 3e28eed9ec2249bb11ad0db4629271b7ce9b7918
branch: master
author: St?phane Wirtel
committer: Julien Palard
date: 2018-11-03T16:24:23+01:00
summary:
bpo-34969: Add --fast, --best on the gzip CLI (GH-9833)
files:
A Misc/NEWS.d/next/Library/2018-10-13-07-46-50.bpo-34969.Mfnhjb.rst
M Doc/library/gzip.rst
M Lib/gzip.py
M Lib/test/test_gzip.py
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
index b52dd1a11aa9..a93f37743854 100644
--- a/Doc/library/gzip.rst
+++ b/Doc/library/gzip.rst
@@ -222,25 +222,26 @@ Once executed the :mod:`gzip` module keeps the input file(s).
.. versionchanged:: 3.8
Add a new command line interface with a usage.
+ By default, when you will execute the CLI, the default compression level is 6.
Command line options
^^^^^^^^^^^^^^^^^^^^
.. cmdoption:: file
- .. code-block:: shell-session
+ If *file* is not specified, read from :attr:`sys.stdin`.
- $ python -m gzip file
+.. cmdoption:: --fast
- If *file* is not specified, read from :attr:`sys.stdin`.
+ Indicates the fastest compression method (less compression).
-.. cmdoption:: -d, --decompress
+.. cmdoption:: --best
- Decompress the given file
+ Indicates the slowest compression method (best compression).
- .. code-block:: shell-session
+.. cmdoption:: -d, --decompress
- $ python -m gzip -d file.gz
+ Decompress the given file.
.. cmdoption:: -h, --help
diff --git a/Lib/gzip.py b/Lib/gzip.py
index a34d01ae36e1..151ff1405b16 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -17,7 +17,12 @@
READ, WRITE = 1, 2
-def open(filename, mode="rb", compresslevel=9,
+_COMPRESS_LEVEL_FAST = 1
+_COMPRESS_LEVEL_TRADEOFF = 6
+_COMPRESS_LEVEL_BEST = 9
+
+
+def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_BEST,
encoding=None, errors=None, newline=None):
"""Open a gzip-compressed file in binary or text mode.
@@ -121,7 +126,7 @@ class GzipFile(_compression.BaseStream):
myfileobj = None
def __init__(self, filename=None, mode=None,
- compresslevel=9, fileobj=None, mtime=None):
+ compresslevel=_COMPRESS_LEVEL_BEST, fileobj=None, mtime=None):
"""Constructor for the GzipFile class.
At least one of fileobj and filename must be given a
@@ -515,7 +520,7 @@ def _rewind(self):
super()._rewind()
self._new_member = True
-def compress(data, compresslevel=9):
+def compress(data, compresslevel=_COMPRESS_LEVEL_BEST):
"""Compress data in one shot and return the compressed string.
Optional argument is the compression level, in range of 0-9.
"""
@@ -537,10 +542,21 @@ def main():
parser = ArgumentParser(description=
"A simple command line interface for the gzip module: act like gzip, "
"but do not delete the input file.")
- parser.add_argument("-d", "--decompress", action="store_true",
+ group = parser.add_mutually_exclusive_group()
+ group.add_argument('--fast', action='store_true', help='compress faster')
+ group.add_argument('--best', action='store_true', help='compress better')
+ group.add_argument("-d", "--decompress", action="store_true",
help="act like gunzip instead of gzip")
+
parser.add_argument("args", nargs="*", default=["-"], metavar='file')
args = parser.parse_args()
+
+ compresslevel = _COMPRESS_LEVEL_TRADEOFF
+ if args.fast:
+ compresslevel = _COMPRESS_LEVEL_FAST
+ elif args.best:
+ compresslevel = _COMPRESS_LEVEL_BEST
+
for arg in args.args:
if args.decompress:
if arg == "-":
@@ -555,7 +571,8 @@ def main():
else:
if arg == "-":
f = sys.stdin.buffer
- g = GzipFile(filename="", mode="wb", fileobj=sys.stdout.buffer)
+ g = GzipFile(filename="", mode="wb", fileobj=sys.stdout.buffer,
+ compresslevel=compresslevel)
else:
f = builtins.open(arg, "rb")
g = open(arg + ".gz", "wb")
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index b072ce4682c0..1e8b41f07b3e 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -12,7 +12,7 @@
from subprocess import PIPE, Popen
from test import support
from test.support import _4G, bigmemtest
-from test.support.script_helper import assert_python_ok
+from test.support.script_helper import assert_python_ok, assert_python_failure
gzip = support.import_module('gzip')
@@ -746,10 +746,38 @@ def test_compress_infile_outfile(self):
rc, out, err = assert_python_ok('-m', 'gzip', local_testgzip)
self.assertTrue(os.path.exists(gzipname))
- self.assertEqual(rc, 0)
self.assertEqual(out, b'')
self.assertEqual(err, b'')
+ @create_and_remove_directory(TEMPDIR)
+ def test_compress_infile_outfile(self):
+ for compress_level in ('--fast', '--best'):
+ with self.subTest(compress_level=compress_level):
+ local_testgzip = os.path.join(TEMPDIR, 'testgzip')
+ gzipname = local_testgzip + '.gz'
+ self.assertFalse(os.path.exists(gzipname))
+
+ with open(local_testgzip, 'wb') as fp:
+ fp.write(self.data)
+
+ rc, out, err = assert_python_ok('-m', 'gzip', compress_level, local_testgzip)
+
+ self.assertTrue(os.path.exists(gzipname))
+ self.assertEqual(out, b'')
+ self.assertEqual(err, b'')
+ os.remove(gzipname)
+ self.assertFalse(os.path.exists(gzipname))
+
+ def test_compress_fast_best_are_exclusive(self):
+ rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '--best')
+ self.assertIn(b"error: argument --best: not allowed with argument --fast", err)
+ self.assertEqual(out, b'')
+
+ def test_decompress_cannot_have_flags_compression(self):
+ rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '-d')
+ self.assertIn(b'error: argument -d/--decompress: not allowed with argument --fast', err)
+ self.assertEqual(out, b'')
+
def test_main(verbose=None):
support.run_unittest(TestGzip, TestOpen, TestCommandLine)
diff --git a/Misc/NEWS.d/next/Library/2018-10-13-07-46-50.bpo-34969.Mfnhjb.rst b/Misc/NEWS.d/next/Library/2018-10-13-07-46-50.bpo-34969.Mfnhjb.rst
new file mode 100644
index 000000000000..e3b713261406
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-10-13-07-46-50.bpo-34969.Mfnhjb.rst
@@ -0,0 +1,3 @@
+gzip: Add --fast, --best on the gzip CLI, these parameters will be used for the
+fast compression method (quick) or the best method compress (slower, but smaller
+file). Also, change the default compression level to 6 (tradeoff).
From webhook-mailer at python.org Sat Nov 3 13:41:42 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Sat, 03 Nov 2018 17:41:42 -0000
Subject: [Python-checkins] Fix a typo about a comma. (GH-10306)
Message-ID:
https://github.com/python/cpython/commit/133fd6527d66e0e744210e0494762a67ff02a6c4
commit: 133fd6527d66e0e744210e0494762a67ff02a6c4
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-03T10:41:38-07:00
summary:
Fix a typo about a comma. (GH-10306)
(cherry picked from commit fe62d877e300e1ee4145fff8f2bdba498b685f91)
Co-authored-by: ?smail Ar?l?k
files:
M Doc/tutorial/errors.rst
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index aba61da5f7c3..957cbf962b20 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -314,7 +314,7 @@ to create specific exception classes for different error conditions::
self.next = next
self.message = message
-Most exceptions are defined with names that end in "Error," similar to the
+Most exceptions are defined with names that end in "Error", similar to the
naming of the standard exceptions.
Many standard modules define their own exceptions to report errors that may
From webhook-mailer at python.org Sat Nov 3 13:41:48 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Sat, 03 Nov 2018 17:41:48 -0000
Subject: [Python-checkins] Fix a typo about a comma. (GH-10306)
Message-ID:
https://github.com/python/cpython/commit/4614b983b600425ed198d2d2407ca77316762531
commit: 4614b983b600425ed198d2d2407ca77316762531
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-03T10:41:45-07:00
summary:
Fix a typo about a comma. (GH-10306)
(cherry picked from commit fe62d877e300e1ee4145fff8f2bdba498b685f91)
Co-authored-by: ?smail Ar?l?k
files:
M Doc/tutorial/errors.rst
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index aba61da5f7c3..957cbf962b20 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -314,7 +314,7 @@ to create specific exception classes for different error conditions::
self.next = next
self.message = message
-Most exceptions are defined with names that end in "Error," similar to the
+Most exceptions are defined with names that end in "Error", similar to the
naming of the standard exceptions.
Many standard modules define their own exceptions to report errors that may
From webhook-mailer at python.org Sat Nov 3 13:41:59 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Sat, 03 Nov 2018 17:41:59 -0000
Subject: [Python-checkins] Fix a typo about a comma. (GH-10306)
Message-ID:
https://github.com/python/cpython/commit/421b41b096fa953819e223dc3e0bcce5d57231ea
commit: 421b41b096fa953819e223dc3e0bcce5d57231ea
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-03T10:41:56-07:00
summary:
Fix a typo about a comma. (GH-10306)
(cherry picked from commit fe62d877e300e1ee4145fff8f2bdba498b685f91)
Co-authored-by: ?smail Ar?l?k
files:
M Doc/tutorial/errors.rst
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index 466009e51e7b..247dda761c00 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -315,7 +315,7 @@ to create specific exception classes for different error conditions::
self.next = next
self.msg = msg
-Most exceptions are defined with names that end in "Error," similar to the
+Most exceptions are defined with names that end in "Error", similar to the
naming of the standard exceptions.
Many standard modules define their own exceptions to report errors that may
From webhook-mailer at python.org Sat Nov 3 14:06:37 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sat, 03 Nov 2018 18:06:37 -0000
Subject: [Python-checkins] Doc: -W flag for sphinx-build can be disabled
(GH-10303)
Message-ID:
https://github.com/python/cpython/commit/f98c1623ec90508937afc1b58556e38214d70892
commit: f98c1623ec90508937afc1b58556e38214d70892
branch: master
author: Julien Palard
committer: GitHub
date: 2018-11-03T19:06:33+01:00
summary:
Doc: -W flag for sphinx-build can be disabled (GH-10303)
files:
M Doc/Makefile
diff --git a/Doc/Makefile b/Doc/Makefile
index 50beac58ec38..4b85e9eb6058 100644
--- a/Doc/Makefile
+++ b/Doc/Makefile
@@ -11,9 +11,10 @@ BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
PAPER =
SOURCES =
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
+SPHINXERRORHANDLING = -W
-ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -W -D latex_elements.papersize=$(PAPER) \
- $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
+ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_elements.papersize=$(PAPER) \
+ $(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
.PHONY: help build html htmlhelp latex text changes linkcheck \
suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
From solipsis at pitrou.net Sun Nov 4 04:08:40 2018
From: solipsis at pitrou.net (solipsis at pitrou.net)
Date: Sun, 04 Nov 2018 09:08:40 +0000
Subject: [Python-checkins] Daily reference leaks (4243df51fe43): sum=3
Message-ID: <20181104090840.1.65E1BD18079D5480@psf.io>
results for 4243df51fe43 on branch "default"
--------------------------------------------
test_functools leaked [0, 3, 1] memory blocks, sum=4
test_multiprocessing_spawn leaked [0, 1, -2] memory blocks, sum=-1
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogGHvho7', '--timeout', '7200']
From webhook-mailer at python.org Sun Nov 4 09:50:59 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sun, 04 Nov 2018 14:50:59 -0000
Subject: [Python-checkins] Explain that the orderness of the result of glob
is system-dependant (GH-6587)
Message-ID:
https://github.com/python/cpython/commit/52465e1b8bb7af23d642dbb43c8173d079b7ec30
commit: 52465e1b8bb7af23d642dbb43c8173d079b7ec30
branch: master
author: Elena Oat
committer: Julien Palard
date: 2018-11-04T15:50:55+01:00
summary:
Explain that the orderness of the result of glob is system-dependant (GH-6587)
Thanks!
files:
M Doc/library/glob.rst
diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst
index 0db10b5efc10..2a5f0ddc4ef3 100644
--- a/Doc/library/glob.rst
+++ b/Doc/library/glob.rst
@@ -42,7 +42,8 @@ For example, ``'[?]'`` matches the character ``'?'``.
a string containing a path specification. *pathname* can be either absolute
(like :file:`/usr/src/Python-1.5/Makefile`) or relative (like
:file:`../../Tools/\*/\*.gif`), and can contain shell-style wildcards. Broken
- symlinks are included in the results (as in the shell).
+ symlinks are included in the results (as in the shell). Whether or not the
+ results are sorted depends on the file system.
.. index::
single: **; in glob-style wildcards
From webhook-mailer at python.org Sun Nov 4 10:44:25 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Sun, 04 Nov 2018 15:44:25 -0000
Subject: [Python-checkins] bpo-35161: Fix stack-use-after-scope in
grp.getgr{nam, gid} and pwd.getpw{nam, uid}. (GH-10319)
Message-ID:
https://github.com/python/cpython/commit/e359bc24b1f3a6ce311b9ef3043d1fdf5f1bf1cd
commit: e359bc24b1f3a6ce311b9ef3043d1fdf5f1bf1cd
branch: master
author: Alexey Izbyshev
committer: Serhiy Storchaka
date: 2018-11-04T17:44:16+02:00
summary:
bpo-35161: Fix stack-use-after-scope in grp.getgr{nam,gid} and pwd.getpw{nam,uid}. (GH-10319)
Reported by ASAN.
files:
M Modules/grpmodule.c
M Modules/pwdmodule.c
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index 74286ab3974d..d426f083111e 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -124,11 +124,12 @@ grp_getgrgid_impl(PyObject *module, PyObject *id)
Py_DECREF(py_int_id);
}
#ifdef HAVE_GETGRGID_R
- Py_BEGIN_ALLOW_THREADS
int status;
Py_ssize_t bufsize;
+ /* Note: 'grp' will be used via pointer 'p' on getgrgid_r success. */
struct group grp;
+ Py_BEGIN_ALLOW_THREADS
bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
if (bufsize == -1) {
bufsize = DEFAULT_BUFFER_SIZE;
@@ -204,11 +205,12 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
if (PyBytes_AsStringAndSize(bytes, &name_chars, NULL) == -1)
goto out;
#ifdef HAVE_GETGRNAM_R
- Py_BEGIN_ALLOW_THREADS
int status;
Py_ssize_t bufsize;
+ /* Note: 'grp' will be used via pointer 'p' on getgrnam_r success. */
struct group grp;
+ Py_BEGIN_ALLOW_THREADS
bufsize = sysconf(_SC_GETGR_R_SIZE_MAX);
if (bufsize == -1) {
bufsize = DEFAULT_BUFFER_SIZE;
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index d15286dc10fc..1286e7d5ce59 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -131,11 +131,12 @@ pwd_getpwuid(PyObject *module, PyObject *uidobj)
return NULL;
}
#ifdef HAVE_GETPWUID_R
- Py_BEGIN_ALLOW_THREADS
int status;
Py_ssize_t bufsize;
+ /* Note: 'pwd' will be used via pointer 'p' on getpwuid_r success. */
struct passwd pwd;
+ Py_BEGIN_ALLOW_THREADS
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize == -1) {
bufsize = DEFAULT_BUFFER_SIZE;
@@ -212,11 +213,12 @@ pwd_getpwnam_impl(PyObject *module, PyObject *name)
if (PyBytes_AsStringAndSize(bytes, &name_chars, NULL) == -1)
goto out;
#ifdef HAVE_GETPWNAM_R
- Py_BEGIN_ALLOW_THREADS
int status;
Py_ssize_t bufsize;
+ /* Note: 'pwd' will be used via pointer 'p' on getpwnam_r success. */
struct passwd pwd;
+ Py_BEGIN_ALLOW_THREADS
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize == -1) {
bufsize = DEFAULT_BUFFER_SIZE;
From webhook-mailer at python.org Sun Nov 4 14:38:53 2018
From: webhook-mailer at python.org (Ned Deily)
Date: Sun, 04 Nov 2018 19:38:53 -0000
Subject: [Python-checkins] [2.7] Docs: fix some wrong words (GH-6987)
(GH-10315)
Message-ID:
https://github.com/python/cpython/commit/6bf85acf601fddc27ae2941af1f1fde7c5fccb89
commit: 6bf85acf601fddc27ae2941af1f1fde7c5fccb89
branch: 2.7
author: St?phane Wirtel
committer: Ned Deily
date: 2018-11-04T14:38:50-05:00
summary:
[2.7] Docs: fix some wrong words (GH-6987) (GH-10315)
files:
M aclocal.m4
M configure
M configure.ac
diff --git a/aclocal.m4 b/aclocal.m4
index 5e29449ae2a1..df7895b88496 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -12,9 +12,9 @@
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
-dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-dnl serial 11 (pkg-config-0.29.1)
-dnl
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 11 (pkg-config-0.29.1)
+
dnl Copyright ? 2004 Scott James Remnant .
dnl Copyright ? 2012-2015 Dan Nicholson
dnl
@@ -288,3 +288,71 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
+dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
+dnl [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------
+dnl
+dnl Prepare a "--with-" configure option using the lowercase
+dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
+dnl PKG_CHECK_MODULES in a single macro.
+AC_DEFUN([PKG_WITH_MODULES],
+[
+m4_pushdef([with_arg], m4_tolower([$1]))
+
+m4_pushdef([description],
+ [m4_default([$5], [build with ]with_arg[ support])])
+
+m4_pushdef([def_arg], [m4_default([$6], [auto])])
+m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
+m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
+
+m4_case(def_arg,
+ [yes],[m4_pushdef([with_without], [--without-]with_arg)],
+ [m4_pushdef([with_without],[--with-]with_arg)])
+
+AC_ARG_WITH(with_arg,
+ AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
+ [AS_TR_SH([with_]with_arg)=def_arg])
+
+AS_CASE([$AS_TR_SH([with_]with_arg)],
+ [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
+ [auto],[PKG_CHECK_MODULES([$1],[$2],
+ [m4_n([def_action_if_found]) $3],
+ [m4_n([def_action_if_not_found]) $4])])
+
+m4_popdef([with_arg])
+m4_popdef([description])
+m4_popdef([def_arg])
+
+])dnl PKG_WITH_MODULES
+
+dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl [DESCRIPTION], [DEFAULT])
+dnl -----------------------------------------------
+dnl
+dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
+dnl check._[VARIABLE-PREFIX] is exported as make variable.
+AC_DEFUN([PKG_HAVE_WITH_MODULES],
+[
+PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
+
+AM_CONDITIONAL([HAVE_][$1],
+ [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
+])dnl PKG_HAVE_WITH_MODULES
+
+dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
+dnl [DESCRIPTION], [DEFAULT])
+dnl ------------------------------------------------------
+dnl
+dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
+dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
+dnl and preprocessor variable.
+AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
+[
+PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
+
+AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
+ [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
+])dnl PKG_HAVE_DEFINE_WITH_MODULES
+
diff --git a/configure b/configure
index ea8527fea18b..3d9a8392ff59 100755
--- a/configure
+++ b/configure
@@ -769,7 +769,6 @@ infodir
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -881,7 +880,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1134,15 +1132,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1280,7 +1269,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1433,7 +1422,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -3052,7 +3040,7 @@ if test "${enable_universalsdk+set}" = set; then :
enableval=$enable_universalsdk;
case $enableval in
yes)
- # Locate the best usable SDK, see Mac/README.txt for more
+ # Locate the best usable SDK, see Mac/README for more
# information
enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
diff --git a/configure.ac b/configure.ac
index 5dfb824b93f1..aecf6066e8ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,7 +117,7 @@ AC_ARG_ENABLE(universalsdk,
[
case $enableval in
yes)
- # Locate the best usable SDK, see Mac/README.txt for more
+ # Locate the best usable SDK, see Mac/README for more
# information
enableval="`/usr/bin/xcodebuild -version -sdk macosx Path 2>/dev/null`"
if ! ( echo $enableval | grep -E '\.sdk' 1>/dev/null )
From webhook-mailer at python.org Sun Nov 4 15:41:37 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sun, 04 Nov 2018 20:41:37 -0000
Subject: [Python-checkins] bpo-35159: Add a link to the devguide in the
sidebar of the index (Doc/) (GH-10316)
Message-ID:
https://github.com/python/cpython/commit/0edc7b1b1a2b22d4d200f80995454d01927bf93e
commit: 0edc7b1b1a2b22d4d200f80995454d01927bf93e
branch: master
author: St?phane Wirtel
committer: Julien Palard
date: 2018-11-04T21:41:34+01:00
summary:
bpo-35159: Add a link to the devguide in the sidebar of the index (Doc/) (GH-10316)
files:
M Doc/tools/templates/indexsidebar.html
diff --git a/Doc/tools/templates/indexsidebar.html b/Doc/tools/templates/indexsidebar.html
index 327452484cc8..8abce8ed6a87 100644
--- a/Doc/tools/templates/indexsidebar.html
+++ b/Doc/tools/templates/indexsidebar.html
@@ -16,4 +16,5 @@ {% trans %}Other resources{% endtrans %}
{% trans %}Beginner's Guide{% endtrans %}
{% trans %}Book List{% endtrans %}
{% trans %}Audio/Visual Talks{% endtrans %}
+ {% trans %}Python Developer?s Guide{% endtrans %}
From webhook-mailer at python.org Sun Nov 4 16:04:54 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sun, 04 Nov 2018 21:04:54 -0000
Subject: [Python-checkins] Doc: Disable smartquotes for zh-tw, zh-cn,
fr and ja translations (GH-9423)
Message-ID:
https://github.com/python/cpython/commit/c03bf0ae794c3bec9b56f38164535fd1f5bfc04a
commit: c03bf0ae794c3bec9b56f38164535fd1f5bfc04a
branch: master
author: Adrian Liaw
committer: Julien Palard
date: 2018-11-04T22:04:51+01:00
summary:
Doc: Disable smartquotes for zh-tw, zh-cn, fr and ja translations (GH-9423)
files:
D Doc/docutils.conf
M Doc/conf.py
diff --git a/Doc/conf.py b/Doc/conf.py
index 6060ac176c95..eb57ee0c9339 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -41,13 +41,18 @@
# By default, highlight as Python 3.
highlight_language = 'python3'
-# Require Sphinx 1.2 for build.
-needs_sphinx = '1.2'
+# Require Sphinx 1.7 for build.
+needs_sphinx = '1.7'
# Ignore any .rst files in the venv/ directory.
venvdir = os.getenv('VENVDIR', 'venv')
exclude_patterns = [venvdir+'/*', 'README.rst']
+# Disable Docutils smartquotes for several translations
+smartquotes_excludes = {
+ 'languages': ['ja', 'fr', 'zh_TW', 'zh_CN'], 'builders': ['man', 'text'],
+}
+
# Options for HTML output
# -----------------------
diff --git a/Doc/docutils.conf b/Doc/docutils.conf
deleted file mode 100644
index bda4f5dc2351..000000000000
--- a/Doc/docutils.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-[restructuredtext parser]
-smartquotes-locales: ja: ""''
From webhook-mailer at python.org Sun Nov 4 16:21:31 2018
From: webhook-mailer at python.org (Ned Deily)
Date: Sun, 04 Nov 2018 21:21:31 -0000
Subject: [Python-checkins] bpo-21263: Skip test_gdb when python has been
compiled with LLVM clang (GH-10318)
Message-ID:
https://github.com/python/cpython/commit/59668aa8b7f174b59304eab833c1c1181886c3c6
commit: 59668aa8b7f174b59304eab833c1c1181886c3c6
branch: master
author: Lysandros Nikolaou
committer: Ned Deily
date: 2018-11-04T16:21:28-05:00
summary:
bpo-21263: Skip test_gdb when python has been compiled with LLVM clang (GH-10318)
files:
A Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
M Lib/test/test_gdb.py
M Misc/ACKS
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 0f950b232533..711fb69ebdff 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -5,6 +5,7 @@
import locale
import os
+import platform
import re
import subprocess
import sys
@@ -48,6 +49,10 @@ def get_gdb_version():
if not sysconfig.is_python_build():
raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
+if 'Clang' in platform.python_compiler() and sys.platform == 'darwin':
+ raise unittest.SkipTest("test_gdb doesn't work correctly when python is"
+ " built with LLVM clang")
+
# Location of custom hooks file in a repository checkout.
checkout_hook_path = os.path.join(os.path.dirname(sys.executable),
'python-gdb.py')
diff --git a/Misc/ACKS b/Misc/ACKS
index 08ff6d11fdd0..89fb0c7000b4 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1147,6 +1147,7 @@ Samuel Nicolary
Jonathan Niehof
Gustavo Niemeyer
Oscar Nierstrasz
+Lysandros Nikolaou
Hrvoje Nik?i?
Gregory Nofi
Jesse Noller
diff --git a/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst b/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
new file mode 100644
index 000000000000..9c6b4ef90706
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
@@ -0,0 +1,4 @@
+After several reports that test_gdb does not work properly on macOS and
+since gdb is not shipped by default anymore, test_gdb is now skipped on
+macOS when LLVM Clang has been used to compile Python. Patch by
+Lysandros Nikolaou
From webhook-mailer at python.org Sun Nov 4 16:40:06 2018
From: webhook-mailer at python.org (Ned Deily)
Date: Sun, 04 Nov 2018 21:40:06 -0000
Subject: [Python-checkins] bpo-21263: Skip test_gdb when python has been
compiled with LLVM clang (GH-10318) (GH-10325)
Message-ID:
https://github.com/python/cpython/commit/96fb350bfd2c9b66d7804ae27ea8c4adbfabad5b
commit: 96fb350bfd2c9b66d7804ae27ea8c4adbfabad5b
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Ned Deily
date: 2018-11-04T16:40:02-05:00
summary:
bpo-21263: Skip test_gdb when python has been compiled with LLVM clang (GH-10318) (GH-10325)
(cherry picked from commit 59668aa8b7f174b59304eab833c1c1181886c3c6)
Co-authored-by: Lysandros Nikolaou
files:
A Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
M Lib/test/test_gdb.py
M Misc/ACKS
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 0f950b232533..711fb69ebdff 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -5,6 +5,7 @@
import locale
import os
+import platform
import re
import subprocess
import sys
@@ -48,6 +49,10 @@ def get_gdb_version():
if not sysconfig.is_python_build():
raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
+if 'Clang' in platform.python_compiler() and sys.platform == 'darwin':
+ raise unittest.SkipTest("test_gdb doesn't work correctly when python is"
+ " built with LLVM clang")
+
# Location of custom hooks file in a repository checkout.
checkout_hook_path = os.path.join(os.path.dirname(sys.executable),
'python-gdb.py')
diff --git a/Misc/ACKS b/Misc/ACKS
index 7cd8ebf26fbf..c35ef1c0fa35 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1136,6 +1136,7 @@ Samuel Nicolary
Jonathan Niehof
Gustavo Niemeyer
Oscar Nierstrasz
+Lysandros Nikolaou
Hrvoje Nik?i?
Gregory Nofi
Jesse Noller
diff --git a/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst b/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
new file mode 100644
index 000000000000..9c6b4ef90706
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
@@ -0,0 +1,4 @@
+After several reports that test_gdb does not work properly on macOS and
+since gdb is not shipped by default anymore, test_gdb is now skipped on
+macOS when LLVM Clang has been used to compile Python. Patch by
+Lysandros Nikolaou
From webhook-mailer at python.org Sun Nov 4 16:40:28 2018
From: webhook-mailer at python.org (Ned Deily)
Date: Sun, 04 Nov 2018 21:40:28 -0000
Subject: [Python-checkins] bpo-21263: Skip test_gdb when python has been
compiled with LLVM clang (GH-10318) (GH-10326)
Message-ID:
https://github.com/python/cpython/commit/f574ce79729ecb01f1f5b3e1a34c8aa7480b79e8
commit: f574ce79729ecb01f1f5b3e1a34c8aa7480b79e8
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Ned Deily
date: 2018-11-04T16:40:25-05:00
summary:
bpo-21263: Skip test_gdb when python has been compiled with LLVM clang (GH-10318) (GH-10326)
(cherry picked from commit 59668aa8b7f174b59304eab833c1c1181886c3c6)
Co-authored-by: Lysandros Nikolaou
files:
A Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
M Lib/test/test_gdb.py
M Misc/ACKS
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index b33d007acbdf..9c15fca43293 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -5,6 +5,7 @@
import locale
import os
+import platform
import re
import subprocess
import sys
@@ -54,6 +55,10 @@ def get_gdb_version():
if not sysconfig.is_python_build():
raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
+if 'Clang' in platform.python_compiler() and sys.platform == 'darwin':
+ raise unittest.SkipTest("test_gdb doesn't work correctly when python is"
+ " built with LLVM clang")
+
# Location of custom hooks file in a repository checkout.
checkout_hook_path = os.path.join(os.path.dirname(sys.executable),
'python-gdb.py')
diff --git a/Misc/ACKS b/Misc/ACKS
index 94731b493c51..c78df75f0dcb 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1107,6 +1107,7 @@ Samuel Nicolary
Jonathan Niehof
Gustavo Niemeyer
Oscar Nierstrasz
+Lysandros Nikolaou
Hrvoje Nik?i?
Gregory Nofi
Jesse Noller
diff --git a/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst b/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
new file mode 100644
index 000000000000..9c6b4ef90706
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-11-04-20-17-09.bpo-21263.T3qo9r.rst
@@ -0,0 +1,4 @@
+After several reports that test_gdb does not work properly on macOS and
+since gdb is not shipped by default anymore, test_gdb is now skipped on
+macOS when LLVM Clang has been used to compile Python. Patch by
+Lysandros Nikolaou
From webhook-mailer at python.org Sun Nov 4 17:12:37 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Sun, 04 Nov 2018 22:12:37 -0000
Subject: [Python-checkins] bpo-31887: Adds documentations for special
multipart/signed handling (GH-4268)
Message-ID:
https://github.com/python/cpython/commit/622935d9a69d12e125e470ce9a9ff3cad9e8e296
commit: 622935d9a69d12e125e470ce9a9ff3cad9e8e296
branch: master
author: Saptak Sengupta
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-11-04T14:12:34-08:00
summary:
bpo-31887: Adds documentations for special multipart/signed handling (GH-4268)
This pull request adds some information about the special multipart/signed handling to clear about disabling header folding.
https://bugs.python.org/issue31887
files:
M Doc/library/email.generator.rst
diff --git a/Doc/library/email.generator.rst b/Doc/library/email.generator.rst
index 2575a5130070..fc535a3e4399 100644
--- a/Doc/library/email.generator.rst
+++ b/Doc/library/email.generator.rst
@@ -36,6 +36,10 @@ something that contains only ASCII characters, using the standard email RFC
Content Transfer Encoding techniques for encoding email messages for transport
over channels that are not "8 bit clean".
+To accomodate reproducible processing of SMIME-signed messages
+:class:`Generator` disables header folding for message parts of type
+``multipart/signed`` and all subparts.
+
.. class:: BytesGenerator(outfp, mangle_from_=None, maxheaderlen=None, *, \
policy=None)
From webhook-mailer at python.org Sun Nov 4 17:24:44 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sun, 04 Nov 2018 22:24:44 -0000
Subject: [Python-checkins] bpo-10536: Enhancements to gettext docs (GH-10324)
Message-ID:
https://github.com/python/cpython/commit/55f3317e984cc35bd18ba0326ed98766a2750ffd
commit: 55f3317e984cc35bd18ba0326ed98766a2750ffd
branch: master
author: St?phane Wirtel
committer: Julien Palard
date: 2018-11-04T23:24:41+01:00
summary:
bpo-10536: Enhancements to gettext docs (GH-10324)
files:
A Misc/NEWS.d/next/Documentation/2018-11-04-22-03-56.bpo-10536.a0IsfE.rst
M Doc/library/gettext.rst
diff --git a/Doc/library/gettext.rst b/Doc/library/gettext.rst
index ef315e041e13..38515ebdf591 100644
--- a/Doc/library/gettext.rst
+++ b/Doc/library/gettext.rst
@@ -13,7 +13,7 @@
The :mod:`gettext` module provides internationalization (I18N) and localization
(L10N) services for your Python modules and applications. It supports both the
-GNU ``gettext`` message catalog API and a higher level, class-based API that may
+GNU :program:`gettext` message catalog API and a higher level, class-based API that may
be more appropriate for Python files. The interface described below allows you
to write your module and application messages in one natural language, and
provide a catalog of translated messages for running under different natural
@@ -38,7 +38,7 @@ class-based API instead.
Bind the *domain* to the locale directory *localedir*. More concretely,
:mod:`gettext` will look for binary :file:`.mo` files for the given domain using
- the path (on Unix): :file:`localedir/language/LC_MESSAGES/domain.mo`, where
+ the path (on Unix): :file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo`, where
*languages* is searched for in the environment variables :envvar:`LANGUAGE`,
:envvar:`LC_ALL`, :envvar:`LC_MESSAGES`, and :envvar:`LANG` respectively.
@@ -138,17 +138,16 @@ Class-based API
The class-based API of the :mod:`gettext` module gives you more flexibility and
greater convenience than the GNU :program:`gettext` API. It is the recommended
way of localizing your Python applications and modules. :mod:`!gettext` defines
-a "translations" class which implements the parsing of GNU :file:`.mo` format
-files, and has methods for returning strings. Instances of this "translations"
-class can also install themselves in the built-in namespace as the function
-:func:`_`.
+a :class:`GNUTranslations` class which implements the parsing of GNU :file:`.mo` format
+files, and has methods for returning strings. Instances of this class can also
+install themselves in the built-in namespace as the function :func:`_`.
.. function:: find(domain, localedir=None, languages=None, all=False)
This function implements the standard :file:`.mo` file search algorithm. It
takes a *domain*, identical to what :func:`textdomain` takes. Optional
- *localedir* is as in :func:`bindtextdomain` Optional *languages* is a list of
+ *localedir* is as in :func:`bindtextdomain`. Optional *languages* is a list of
strings, where each string is a language code.
If *localedir* is not given, then the default system locale directory is used.
@@ -172,10 +171,10 @@ class can also install themselves in the built-in namespace as the function
.. function:: translation(domain, localedir=None, languages=None, class_=None, fallback=False, codeset=None)
- Return a :class:`Translations` instance based on the *domain*, *localedir*,
+ Return a :class:`*Translations` instance based on the *domain*, *localedir*,
and *languages*, which are first passed to :func:`find` to get a list of the
associated :file:`.mo` file paths. Instances with identical :file:`.mo` file
- names are cached. The actual class instantiated is either *class_* if
+ names are cached. The actual class instantiated is *class_* if
provided, otherwise :class:`GNUTranslations`. The class's constructor must
take a single :term:`file object` argument. If provided, *codeset* will change
the charset used to encode translated strings in the
@@ -241,7 +240,7 @@ are the methods of :class:`!NullTranslations`:
.. method:: _parse(fp)
- No-op'd in the base class, this method takes file object *fp*, and reads
+ No-op in the base class, this method takes file object *fp*, and reads
the data from the file, initializing its message catalog. If you have an
unsupported message catalog file format, you should override this method
to parse your format.
@@ -285,7 +284,8 @@ are the methods of :class:`!NullTranslations`:
.. method:: info()
- Return the "protected" :attr:`_info` variable.
+ Return the "protected" :attr:`_info` variable, a dictionary containing
+ the metadata found in the message catalog file.
.. method:: charset()
@@ -340,15 +340,15 @@ The :mod:`gettext` module provides one additional class derived from
:meth:`_parse` to enable reading GNU :program:`gettext` format :file:`.mo` files
in both big-endian and little-endian format.
-:class:`GNUTranslations` parses optional meta-data out of the translation
-catalog. It is convention with GNU :program:`gettext` to include meta-data as
-the translation for the empty string. This meta-data is in :rfc:`822`\ -style
+:class:`GNUTranslations` parses optional metadata out of the translation
+catalog. It is convention with GNU :program:`gettext` to include metadata as
+the translation for the empty string. This metadata is in :rfc:`822`\ -style
``key: value`` pairs, and should contain the ``Project-Id-Version`` key. If the
key ``Content-Type`` is found, then the ``charset`` property is used to
initialize the "protected" :attr:`_charset` instance variable, defaulting to
``None`` if not found. If the charset encoding is specified, then all message
ids and message strings read from the catalog are converted to Unicode using
-this encoding, else ASCII encoding is assumed.
+this encoding, else ASCII is assumed.
Since message ids are read as Unicode strings too, all :meth:`*gettext` methods
will assume message ids as Unicode strings, not byte strings.
@@ -452,7 +452,7 @@ take the following steps:
#. run a suite of tools over your marked files to generate raw messages catalogs
-#. create language specific translations of the message catalogs
+#. create language-specific translations of the message catalogs
#. use the :mod:`gettext` module so that message strings are properly translated
@@ -462,9 +462,8 @@ it in ``_('...')`` --- that is, a call to the function :func:`_`. For example::
filename = 'mylog.txt'
message = _('writing a log message')
- fp = open(filename, 'w')
- fp.write(message)
- fp.close()
+ with open(filename, 'w') as fp:
+ fp.write(message)
In this example, the string ``'writing a log message'`` is marked as a candidate
for translation, while the strings ``'mylog.txt'`` and ``'w'`` are not.
@@ -515,7 +514,7 @@ Localizing your module
^^^^^^^^^^^^^^^^^^^^^^
If you are localizing your module, you must take care not to make global
-changes, e.g. to the built-in namespace. You should not use the GNU ``gettext``
+changes, e.g. to the built-in namespace. You should not use the GNU :program:`gettext`
API but instead the class-based API.
Let's say your module is called "spam" and the module's various natural language
@@ -669,8 +668,9 @@ implementations, and valuable experience to the creation of this module:
.. [#] The default locale directory is system dependent; for example, on RedHat Linux
it is :file:`/usr/share/locale`, but on Solaris it is :file:`/usr/lib/locale`.
The :mod:`gettext` module does not try to support these system dependent
- defaults; instead its default is :file:`sys.prefix/share/locale`. For this
- reason, it is always best to call :func:`bindtextdomain` with an explicit
- absolute path at the start of your application.
+ defaults; instead its default is :file:`{sys.prefix}/share/locale` (see
+ :data:`sys.prefix`). For this reason, it is always best to call
+ :func:`bindtextdomain` with an explicit absolute path at the start of your
+ application.
.. [#] See the footnote for :func:`bindtextdomain` above.
diff --git a/Misc/NEWS.d/next/Documentation/2018-11-04-22-03-56.bpo-10536.a0IsfE.rst b/Misc/NEWS.d/next/Documentation/2018-11-04-22-03-56.bpo-10536.a0IsfE.rst
new file mode 100644
index 000000000000..b5036481fb65
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2018-11-04-22-03-56.bpo-10536.a0IsfE.rst
@@ -0,0 +1 @@
+Enhance the gettext docs. Patch by ?ric Araujo
From webhook-mailer at python.org Sun Nov 4 17:34:25 2018
From: webhook-mailer at python.org (Raymond Hettinger)
Date: Sun, 04 Nov 2018 22:34:25 -0000
Subject: [Python-checkins] bpo-35118: Improve docs regarding indexing
(GH-10265)
Message-ID:
https://github.com/python/cpython/commit/98b85354153883b0a080f678f213729cd0764fee
commit: 98b85354153883b0a080f678f213729cd0764fee
branch: master
author: Windson yang
committer: Raymond Hettinger
date: 2018-11-04T14:34:22-08:00
summary:
bpo-35118: Improve docs regarding indexing (GH-10265)
files:
M Doc/library/collections.rst
M Doc/library/queue.rst
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 495cfc2c234f..6b9d85abaae7 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -531,9 +531,9 @@ or subtracting from an empty counter.
In addition to the above, deques support iteration, pickling, ``len(d)``,
``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with
-the :keyword:`in` operator, and subscript references such as ``d[-1]``. Indexed
-access is O(1) at both ends but slows to O(n) in the middle. For fast random
-access, use lists instead.
+the :keyword:`in` operator, and subscript references such as ``d[0]`` to access
+the first element. Indexed access is O(1) at both ends but slows to O(n) in
+the middle. For fast random access, use lists instead.
Starting in version 3.5, deques support ``__add__()``, ``__mul__()``,
and ``__imul__()``.
diff --git a/Doc/library/queue.rst b/Doc/library/queue.rst
index 1fea86bfc5cd..f99f6ffb05f6 100644
--- a/Doc/library/queue.rst
+++ b/Doc/library/queue.rst
@@ -275,4 +275,5 @@ SimpleQueue Objects
:class:`collections.deque` is an alternative implementation of unbounded
queues with fast atomic :meth:`~collections.deque.append` and
- :meth:`~collections.deque.popleft` operations that do not require locking.
+ :meth:`~collections.deque.popleft` operations that do not require locking
+ and also support indexing.
From webhook-mailer at python.org Sun Nov 4 17:36:28 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Sun, 04 Nov 2018 22:36:28 -0000
Subject: [Python-checkins] bpo-9842: Add cross-reference to the ellipsis
object (GH-4063)
Message-ID:
https://github.com/python/cpython/commit/b4db249c9544fc4425c32feb86d610f3224ca3d8
commit: b4db249c9544fc4425c32feb86d610f3224ca3d8
branch: master
author: Pablo Galindo
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-11-04T14:36:25-08:00
summary:
bpo-9842: Add cross-reference to the ellipsis object (GH-4063)
This PR adds a cross-reference to the ellipsis object and the representation of recursive item in containers as indicated in [issue 9842](https://bugs.python.org/issue9842) by @bitdancer.
https://bugs.python.org/issue9842
files:
M Doc/glossary.rst
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index b8e773741ce7..02adc0c56ece 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -13,10 +13,14 @@ Glossary
examples which can be executed interactively in the interpreter.
``...``
- The default Python prompt of the interactive shell when entering code for
- an indented code block, when within a pair of matching left and right
- delimiters (parentheses, square brackets, curly braces or triple quotes),
- or after specifying a decorator.
+ Can refer to:
+
+ * The default Python prompt of the interactive shell when entering code for
+ an indented code block, when within a pair of matching left and right
+ delimiters (parentheses, square brackets, curly braces or triple quotes),
+ or after specifying a decorator.
+
+ * The :const:`Ellipsis` built-in constant.
2to3
A tool that tries to convert Python 2.x code to Python 3.x code by
From webhook-mailer at python.org Sun Nov 4 17:40:35 2018
From: webhook-mailer at python.org (Julien Palard)
Date: Sun, 04 Nov 2018 22:40:35 -0000
Subject: [Python-checkins] bpo-19675: Terminate processes if construction of
a pool is failing. (GH-5614)
Message-ID:
https://github.com/python/cpython/commit/5d236cafd7126e640fb25541fcc7e0a494450143
commit: 5d236cafd7126e640fb25541fcc7e0a494450143
branch: master
author: Julien Palard
committer: GitHub
date: 2018-11-04T23:40:32+01:00
summary:
bpo-19675: Terminate processes if construction of a pool is failing. (GH-5614)
files:
A Misc/NEWS.d/next/Library/2018-02-10-23-41-05.bpo-19675.-dj35-.rst
M Lib/multiprocessing/pool.py
M Lib/test/_test_multiprocessing.py
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index 574b5db5afb6..7a6d01490146 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -174,7 +174,15 @@ def __init__(self, processes=None, initializer=None, initargs=(),
self._processes = processes
self._pool = []
- self._repopulate_pool()
+ try:
+ self._repopulate_pool()
+ except Exception:
+ for p in self._pool:
+ if p.exitcode is None:
+ p.terminate()
+ for p in self._pool:
+ p.join()
+ raise
self._worker_handler = threading.Thread(
target=Pool._handle_workers,
@@ -251,10 +259,10 @@ def _repopulate_pool_static(ctx, Process, processes, pool, inqueue,
initargs, maxtasksperchild,
wrap_exception)
)
- pool.append(w)
w.name = w.name.replace('Process', 'PoolWorker')
w.daemon = True
w.start()
+ pool.append(w)
util.debug('added worker')
@staticmethod
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index dc59e9fd740a..7993fcb08e46 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3,6 +3,7 @@
#
import unittest
+import unittest.mock
import queue as pyqueue
import contextlib
import time
@@ -4635,6 +4636,48 @@ def test_empty(self):
proc.join()
+class TestPoolNotLeakOnFailure(unittest.TestCase):
+
+ def test_release_unused_processes(self):
+ # Issue #19675: During pool creation, if we can't create a process,
+ # don't leak already created ones.
+ will_fail_in = 3
+ forked_processes = []
+
+ class FailingForkProcess:
+ def __init__(self, **kwargs):
+ self.name = 'Fake Process'
+ self.exitcode = None
+ self.state = None
+ forked_processes.append(self)
+
+ def start(self):
+ nonlocal will_fail_in
+ if will_fail_in <= 0:
+ raise OSError("Manually induced OSError")
+ will_fail_in -= 1
+ self.state = 'started'
+
+ def terminate(self):
+ self.state = 'stopping'
+
+ def join(self):
+ if self.state == 'stopping':
+ self.state = 'stopped'
+
+ def is_alive(self):
+ return self.state == 'started' or self.state == 'stopping'
+
+ with self.assertRaisesRegex(OSError, 'Manually induced OSError'):
+ p = multiprocessing.pool.Pool(5, context=unittest.mock.MagicMock(
+ Process=FailingForkProcess))
+ p.close()
+ p.join()
+ self.assertFalse(
+ any(process.is_alive() for process in forked_processes))
+
+
+
class MiscTestCase(unittest.TestCase):
def test__all__(self):
# Just make sure names in blacklist are excluded
diff --git a/Misc/NEWS.d/next/Library/2018-02-10-23-41-05.bpo-19675.-dj35-.rst b/Misc/NEWS.d/next/Library/2018-02-10-23-41-05.bpo-19675.-dj35-.rst
new file mode 100644
index 000000000000..958550d3e8d7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-02-10-23-41-05.bpo-19675.-dj35-.rst
@@ -0,0 +1 @@
+``multiprocessing.Pool`` no longer leaks processes if its initialization fails.
From webhook-mailer at python.org Sun Nov 4 18:58:28 2018
From: webhook-mailer at python.org (Benjamin Peterson)
Date: Sun, 04 Nov 2018 23:58:28 -0000
Subject: [Python-checkins] closes bpo-32285: Add unicodedata.is_normalized.
(GH-4806)
Message-ID:
https://github.com/python/cpython/commit/2810dd7be9876236f74ac80716d113572c9098dd
commit: 2810dd7be9876236f74ac80716d113572c9098dd
branch: master
author: Max B?langer
committer: Benjamin Peterson
date: 2018-11-04T15:58:24-08:00
summary:
closes bpo-32285: Add unicodedata.is_normalized. (GH-4806)
files:
A Misc/NEWS.d/next/Core and Builtins/2017-12-12-13-43-13.bpo-32285.LzKSwz.rst
M Doc/library/unicodedata.rst
M Doc/whatsnew/3.8.rst
M Lib/test/test_normalization.py
M Modules/clinic/unicodedata.c.h
M Modules/unicodedata.c
diff --git a/Doc/library/unicodedata.rst b/Doc/library/unicodedata.rst
index 59548f3e8b4a..17e848bf552b 100644
--- a/Doc/library/unicodedata.rst
+++ b/Doc/library/unicodedata.rst
@@ -133,6 +133,13 @@ following functions:
a human reader, if one has combining characters and the other
doesn't, they may not compare equal.
+.. function:: is_normalized(form, unistr)
+
+ Return whether the Unicode string *unistr* is in the normal form *form*. Valid
+ values for *form* are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
+
+ .. versionadded:: 3.8
+
In addition, the module exposes the following constant:
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 5397206030fe..566c369c85bd 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -204,6 +204,13 @@ Added method :meth:`~tkinter.Canvas.moveto`
in the :class:`tkinter.Canvas` class.
(Contributed by Juliette Monsel in :issue:`23831`.)
+unicodedata
+-----------
+
+* New function :func:`~unicodedata.is_normalized` can be used to verify a string
+ is in a specific normal form. (Contributed by Max Belanger and David Euresti in
+ :issue:`32285`).
+
venv
----
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index 304245644502..ba877e73f7d9 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -3,7 +3,7 @@
from http.client import HTTPException
import sys
-from unicodedata import normalize, unidata_version
+from unicodedata import normalize, is_normalized, unidata_version
TESTDATAFILE = "NormalizationTest.txt"
TESTDATAURL = "http://www.pythontest.net/unicode/" + unidata_version + "/" + TESTDATAFILE
@@ -88,6 +88,15 @@ def run_normalization_tests(self, testdata):
NFKD(c3) == NFKD(c4) == NFKD(c5),
line)
+ self.assertTrue(is_normalized("NFC", c2))
+ self.assertTrue(is_normalized("NFC", c4))
+
+ self.assertTrue(is_normalized("NFD", c3))
+ self.assertTrue(is_normalized("NFD", c5))
+
+ self.assertTrue(is_normalized("NFKC", c4))
+ self.assertTrue(is_normalized("NFKD", c5))
+
# Record part 1 data
if part == "@Part1":
part1_data[c1] = 1
diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-12-12-13-43-13.bpo-32285.LzKSwz.rst b/Misc/NEWS.d/next/Core and Builtins/2017-12-12-13-43-13.bpo-32285.LzKSwz.rst
new file mode 100644
index 000000000000..87f84b02eb84
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2017-12-12-13-43-13.bpo-32285.LzKSwz.rst
@@ -0,0 +1,2 @@
+New function unicodedata.is_normalized, which can check whether a string is
+in a specific normal form.
diff --git a/Modules/clinic/unicodedata.c.h b/Modules/clinic/unicodedata.c.h
index 72e3f6545778..54021fedba41 100644
--- a/Modules/clinic/unicodedata.c.h
+++ b/Modules/clinic/unicodedata.c.h
@@ -284,6 +284,38 @@ unicodedata_UCD_decomposition(PyObject *self, PyObject *arg)
return return_value;
}
+PyDoc_STRVAR(unicodedata_UCD_is_normalized__doc__,
+"is_normalized($self, form, unistr, /)\n"
+"--\n"
+"\n"
+"Return whether the Unicode string unistr is in the normal form \'form\'.\n"
+"\n"
+"Valid values for form are \'NFC\', \'NFKC\', \'NFD\', and \'NFKD\'.");
+
+#define UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF \
+ {"is_normalized", (PyCFunction)unicodedata_UCD_is_normalized, METH_FASTCALL, unicodedata_UCD_is_normalized__doc__},
+
+static PyObject *
+unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
+ PyObject *input);
+
+static PyObject *
+unicodedata_UCD_is_normalized(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *form;
+ PyObject *input;
+
+ if (!_PyArg_ParseStack(args, nargs, "UU:is_normalized",
+ &form, &input)) {
+ goto exit;
+ }
+ return_value = unicodedata_UCD_is_normalized_impl(self, form, input);
+
+exit:
+ return return_value;
+}
+
PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
"normalize($self, form, unistr, /)\n"
"--\n"
@@ -296,17 +328,17 @@ PyDoc_STRVAR(unicodedata_UCD_normalize__doc__,
{"normalize", (PyCFunction)unicodedata_UCD_normalize, METH_FASTCALL, unicodedata_UCD_normalize__doc__},
static PyObject *
-unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
+unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
PyObject *input);
static PyObject *
unicodedata_UCD_normalize(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
- const char *form;
+ PyObject *form;
PyObject *input;
- if (!_PyArg_ParseStack(args, nargs, "sU:normalize",
+ if (!_PyArg_ParseStack(args, nargs, "UU:normalize",
&form, &input)) {
goto exit;
}
@@ -379,4 +411,4 @@ unicodedata_UCD_lookup(PyObject *self, PyObject *arg)
exit:
return return_value;
}
-/*[clinic end generated code: output=dc899bff0ecd14c1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2c5fbf597c18f6b8 input=a9049054013a1b77]*/
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index e8788f5036dd..9ceab1b3db4f 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -19,6 +19,11 @@
#include "ucnhash.h"
#include "structmember.h"
+_Py_IDENTIFIER(NFC);
+_Py_IDENTIFIER(NFD);
+_Py_IDENTIFIER(NFKC);
+_Py_IDENTIFIER(NFKD);
+
/*[clinic input]
module unicodedata
class unicodedata.UCD 'PreviousDBVersion *' '&UCD_Type'
@@ -770,8 +775,10 @@ nfc_nfkc(PyObject *self, PyObject *input, int k)
return result;
}
-/* Return 1 if the input is certainly normalized, 0 if it might not be. */
-static int
+typedef enum {YES, NO, MAYBE} NormalMode;
+
+/* Return YES if the input is certainly normalized, NO or MAYBE if it might not be. */
+static NormalMode
is_normalized(PyObject *self, PyObject *input, int nfc, int k)
{
Py_ssize_t i, len;
@@ -782,7 +789,7 @@ is_normalized(PyObject *self, PyObject *input, int nfc, int k)
/* An older version of the database is requested, quickchecks must be
disabled. */
if (self && UCD_Check(self))
- return 0;
+ return NO;
/* The two quickcheck bits at this shift mean 0=Yes, 1=Maybe, 2=No,
as described in http://unicode.org/reports/tr15/#Annex8. */
@@ -799,19 +806,92 @@ is_normalized(PyObject *self, PyObject *input, int nfc, int k)
unsigned char quickcheck = record->normalization_quick_check;
if (quickcheck & quickcheck_mask)
- return 0; /* this string might need normalization */
+ return MAYBE; /* this string might need normalization */
if (combining && prev_combining > combining)
- return 0; /* non-canonical sort order, not normalized */
+ return NO; /* non-canonical sort order, not normalized */
prev_combining = combining;
}
- return 1; /* certainly normalized */
+ return YES; /* certainly normalized */
+}
+
+/*[clinic input]
+unicodedata.UCD.is_normalized
+
+ self: self
+ form: unicode
+ unistr as input: unicode
+ /
+
+Return whether the Unicode string unistr is in the normal form 'form'.
+
+Valid values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
+[clinic start generated code]*/
+
+static PyObject *
+unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
+ PyObject *input)
+/*[clinic end generated code: output=11e5a3694e723ca5 input=a544f14cea79e508]*/
+{
+ if (PyUnicode_READY(input) == -1) {
+ return NULL;
+ }
+
+ if (PyUnicode_GET_LENGTH(input) == 0) {
+ /* special case empty input strings. */
+ Py_RETURN_TRUE;
+ }
+
+ PyObject *result;
+ int nfc = 0;
+ int k = 0;
+ NormalMode m;
+
+ PyObject *cmp;
+ int match = 0;
+
+ if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
+ nfc = 1;
+ }
+ else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
+ nfc = 1;
+ k = 1;
+ }
+ else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
+ /* matches default values for `nfc` and `k` */
+ }
+ else if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
+ k = 1;
+ }
+ else {
+ PyErr_SetString(PyExc_ValueError, "invalid normalization form");
+ return NULL;
+ }
+
+ m = is_normalized(self, input, nfc, k);
+
+ if (m == MAYBE) {
+ cmp = (nfc ? nfc_nfkc : nfd_nfkd)(self, input, k);
+ if (cmp == NULL) {
+ return NULL;
+ }
+ match = PyUnicode_Compare(input, cmp);
+ Py_DECREF(cmp);
+ result = (match == 0) ? Py_True : Py_False;
+ }
+ else {
+ result = (m == YES) ? Py_True : Py_False;
+ }
+
+ Py_INCREF(result);
+ return result;
}
+
/*[clinic input]
unicodedata.UCD.normalize
self: self
- form: str
+ form: unicode
unistr as input: unicode
/
@@ -821,9 +901,9 @@ Valid values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
[clinic start generated code]*/
static PyObject *
-unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
+unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
PyObject *input)
-/*[clinic end generated code: output=62d1f8870027efdc input=1744c55f4ab79bf0]*/
+/*[clinic end generated code: output=05ca4385a2ad6983 input=3a5206c0ad2833fb]*/
{
if (PyUnicode_GET_LENGTH(input) == 0) {
/* Special case empty input strings, since resizing
@@ -832,29 +912,29 @@ unicodedata_UCD_normalize_impl(PyObject *self, const char *form,
return input;
}
- if (strcmp(form, "NFC") == 0) {
- if (is_normalized(self, input, 1, 0)) {
+ if (_PyUnicode_EqualToASCIIId(form, &PyId_NFC)) {
+ if (is_normalized(self, input, 1, 0) == YES) {
Py_INCREF(input);
return input;
}
return nfc_nfkc(self, input, 0);
}
- if (strcmp(form, "NFKC") == 0) {
- if (is_normalized(self, input, 1, 1)) {
+ if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKC)) {
+ if (is_normalized(self, input, 1, 1) == YES) {
Py_INCREF(input);
return input;
}
return nfc_nfkc(self, input, 1);
}
- if (strcmp(form, "NFD") == 0) {
- if (is_normalized(self, input, 0, 0)) {
+ if (_PyUnicode_EqualToASCIIId(form, &PyId_NFD)) {
+ if (is_normalized(self, input, 0, 0) == YES) {
Py_INCREF(input);
return input;
}
return nfd_nfkd(self, input, 0);
}
- if (strcmp(form, "NFKD") == 0) {
- if (is_normalized(self, input, 0, 1)) {
+ if (_PyUnicode_EqualToASCIIId(form, &PyId_NFKD)) {
+ if (is_normalized(self, input, 0, 1) == YES) {
Py_INCREF(input);
return input;
}
@@ -1271,6 +1351,7 @@ static PyMethodDef unicodedata_functions[] = {
UNICODEDATA_UCD_DECOMPOSITION_METHODDEF
UNICODEDATA_UCD_NAME_METHODDEF
UNICODEDATA_UCD_LOOKUP_METHODDEF
+ UNICODEDATA_UCD_IS_NORMALIZED_METHODDEF
UNICODEDATA_UCD_NORMALIZE_METHODDEF
{NULL, NULL} /* sentinel */
};
From solipsis at pitrou.net Mon Nov 5 04:08:22 2018
From: solipsis at pitrou.net (solipsis at pitrou.net)
Date: Mon, 05 Nov 2018 09:08:22 +0000
Subject: [Python-checkins] Daily reference leaks (4243df51fe43): sum=5
Message-ID: <20181105090822.1.C4799BC288E7A51B@psf.io>
results for 4243df51fe43 on branch "default"
--------------------------------------------
test_collections leaked [7, -7, 1] memory blocks, sum=1
test_functools leaked [0, 3, 1] memory blocks, sum=4
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogFILtoQ', '--timeout', '7200']
From webhook-mailer at python.org Mon Nov 5 07:03:51 2018
From: webhook-mailer at python.org (Nick Coghlan)
Date: Mon, 05 Nov 2018 12:03:51 -0000
Subject: [Python-checkins] bpo-32512: Add -m option to profile for profiling
modules (#5132)
Message-ID:
https://github.com/python/cpython/commit/ad1a25f499362eaf9cbfcafa0b8e2454eb43dcf1
commit: ad1a25f499362eaf9cbfcafa0b8e2454eb43dcf1
branch: master
author: Mario Corchero
committer: Nick Coghlan
date: 2018-11-05T22:03:46+10:00
summary:
bpo-32512: Add -m option to profile for profiling modules (#5132)
The new option in the CLI of the profile module allow to profile
executable modules. This change follows the same implementation as the
one already present in `cProfile`.
As the argument is now present on both modules, move the tests to the
common test case to be run with profile as well.
files:
A Misc/NEWS.d/next/Library/2018-01-07-17-43-10.bpo-32512.flC-dE.rst
M Doc/library/profile.rst
M Lib/profile.py
M Lib/test/test_cprofile.py
M Lib/test/test_profile.py
diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst
index 1a772fb7f941..9ceb81603c95 100644
--- a/Doc/library/profile.rst
+++ b/Doc/library/profile.rst
@@ -120,8 +120,8 @@ results to a file by specifying a filename to the :func:`run` function::
The :class:`pstats.Stats` class reads profile results from a file and formats
them in various ways.
-The file :mod:`cProfile` can also be invoked as a script to profile another
-script. For example::
+The files :mod:`cProfile` and :mod:`profile` can also be invoked as a script to
+profile another script. For example::
python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)
@@ -133,7 +133,10 @@ the output by. This only applies when ``-o`` is not supplied.
``-m`` specifies that a module is being profiled instead of a script.
.. versionadded:: 3.7
- Added the ``-m`` option.
+ Added the ``-m`` option to :mod:`cProfile`.
+
+ .. versionadded:: 3.8
+ Added the ``-m`` option to :mod:`profile`.
The :mod:`pstats` module's :class:`~pstats.Stats` class has a variety of methods
for manipulating and printing the data saved into a profile results file::
diff --git a/Lib/profile.py b/Lib/profile.py
index 0340a7907bfd..5df43604acdd 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -553,11 +553,13 @@ def main():
import os
from optparse import OptionParser
- usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
+ usage = "profile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ..."
parser = OptionParser(usage=usage)
parser.allow_interspersed_args = False
parser.add_option('-o', '--outfile', dest="outfile",
help="Save stats to ", default=None)
+ parser.add_option('-m', dest="module", action="store_true",
+ help="Profile a library module.", default=False)
parser.add_option('-s', '--sort', dest="sort",
help="Sort order when printing to stdout, based on pstats.Stats class",
default=-1)
@@ -570,16 +572,24 @@ def main():
sys.argv[:] = args
if len(args) > 0:
- progname = args[0]
- sys.path.insert(0, os.path.dirname(progname))
- with open(progname, 'rb') as fp:
- code = compile(fp.read(), progname, 'exec')
- globs = {
- '__file__': progname,
- '__name__': '__main__',
- '__package__': None,
- '__cached__': None,
- }
+ if options.module:
+ import runpy
+ code = "run_module(modname, run_name='__main__')"
+ globs = {
+ 'run_module': runpy.run_module,
+ 'modname': args[0]
+ }
+ else:
+ progname = args[0]
+ sys.path.insert(0, os.path.dirname(progname))
+ with open(progname, 'rb') as fp:
+ code = compile(fp.read(), progname, 'exec')
+ globs = {
+ '__file__': progname,
+ '__name__': '__main__',
+ '__package__': None,
+ '__cached__': None,
+ }
runctx(code, globs, None, options.outfile, options.sort)
else:
parser.print_usage()
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index 406d70305f9e..efcf6bc92803 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -37,19 +37,6 @@ def test_bad_counter_during_dealloc(self):
finally:
unlink(TESTFN)
- # Issue 21862
- def test_module_path_option(self):
- # Test -m switch with modules
-
- # Test that -m switch needs an argument
- assert_python_failure('-m', 'cProfile', '-m')
-
- # Test failure for not-existent module
- assert_python_failure('-m', 'cProfile', '-m', 'random_module_xyz')
-
- # Test successful run
- assert_python_ok('-m', 'cProfile', '-m', 'timeit', '-n', '1')
-
def test_profile_enable_disable(self):
prof = self.profilerclass()
# Make sure we clean ourselves up if the test fails for some reason.
diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py
index a9982663175a..01a8a6eaf5a2 100644
--- a/Lib/test/test_profile.py
+++ b/Lib/test/test_profile.py
@@ -11,6 +11,7 @@
import profile
from test.profilee import testfunc, timer
+from test.support.script_helper import assert_python_failure, assert_python_ok
class ProfileTest(unittest.TestCase):
@@ -98,6 +99,18 @@ def test_runctx(self):
filename=TESTFN)
self.assertTrue(os.path.exists(TESTFN))
+ def test_run_profile_as_module(self):
+ # Test that -m switch needs an argument
+ assert_python_failure('-m', self.profilermodule.__name__, '-m')
+
+ # Test failure for not-existent module
+ assert_python_failure('-m', self.profilermodule.__name__,
+ '-m', 'random_module_xyz')
+
+ # Test successful run
+ assert_python_ok('-m', self.profilermodule.__name__,
+ '-m', 'timeit', '-n', '1')
+
def regenerate_expected_output(filename, cls):
filename = filename.rstrip('co')
diff --git a/Misc/NEWS.d/next/Library/2018-01-07-17-43-10.bpo-32512.flC-dE.rst b/Misc/NEWS.d/next/Library/2018-01-07-17-43-10.bpo-32512.flC-dE.rst
new file mode 100644
index 000000000000..0a7763daffad
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-01-07-17-43-10.bpo-32512.flC-dE.rst
@@ -0,0 +1,2 @@
+:mod:`profile` CLI accepts `-m module_name` as an alternative to
+script path.
From webhook-mailer at python.org Mon Nov 5 09:20:30 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 14:20:30 -0000
Subject: [Python-checkins] bpo-35133: Fix mistakes when concatenate string
literals on different lines. (GH-10284)
Message-ID:
https://github.com/python/cpython/commit/34fd4c20198dea6ab2fe8dc6d32d744d9bde868d
commit: 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d
branch: master
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-05T16:20:25+02:00
summary:
bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings.
files:
M Lib/_pydecimal.py
M Lib/concurrent/futures/thread.py
M Lib/distutils/command/bdist_dumb.py
M Lib/distutils/command/bdist_msi.py
M Lib/distutils/command/bdist_rpm.py
M Lib/distutils/command/bdist_wininst.py
M Lib/distutils/command/build_ext.py
M Lib/email/_header_value_parser.py
M Lib/idlelib/hyperparser.py
M Lib/idlelib/idle_test/htest.py
M Lib/idlelib/idle_test/mock_tk.py
M Lib/importlib/abc.py
M Lib/test/test_builtin.py
M Lib/test/test_compile.py
M Lib/test/test_decimal.py
M Lib/test/test_http_cookiejar.py
M Lib/test/test_range.py
M Lib/test/test_smtplib.py
M Lib/test/test_strptime.py
M Lib/trace.py
M Lib/unittest/mock.py
M Modules/_datetimemodule.c
M Modules/_io/textio.c
M Modules/_pickle.c
M Python/import.c
M Tools/scripts/texi2html.py
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
index 359690003fe1..44ea5b41b2a1 100644
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -2021,7 +2021,7 @@ def _power_modulo(self, other, modulo, context=None):
if not other and not self:
return context._raise_error(InvalidOperation,
'at least one of pow() 1st argument '
- 'and 2nd argument must be nonzero ;'
+ 'and 2nd argument must be nonzero; '
'0**0 is not defined')
# compute sign of result
diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py
index b65dee11f727..78359711d5d9 100644
--- a/Lib/concurrent/futures/thread.py
+++ b/Lib/concurrent/futures/thread.py
@@ -150,7 +150,7 @@ def submit(self, fn, *args, **kwargs):
if self._shutdown:
raise RuntimeError('cannot schedule new futures after shutdown')
if _shutdown:
- raise RuntimeError('cannot schedule new futures after'
+ raise RuntimeError('cannot schedule new futures after '
'interpreter shutdown')
f = _base.Future()
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index e9274d925afa..f0d6b5b8cd8a 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -32,7 +32,7 @@ class bdist_dumb(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('relative', None,
- "build the archive using relative paths"
+ "build the archive using relative paths "
"(default: false)"),
('owner=', 'u',
"Owner name used when creating a tar file"
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index a4bd5a589d38..80104c372d9a 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -98,14 +98,14 @@ class bdist_msi(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index ac4621791d56..02f10dd89d91 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -58,7 +58,7 @@ class bdist_rpm(Command):
"RPM \"vendor\" (eg. \"Joe Blow \") "
"[default: maintainer or author from setup script]"),
('packager=', None,
- "RPM packager (eg. \"Jane Doe \")"
+ "RPM packager (eg. \"Jane Doe \") "
"[default: vendor]"),
('doc-files=', None,
"list of documentation files (space or comma-separated)"),
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index 0871a4f7d6b2..fde56754e891 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -29,7 +29,7 @@ class bdist_wininst(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
@@ -40,7 +40,7 @@ class bdist_wininst(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 8fad9cdc2b47..158465d2338c 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -365,7 +365,7 @@ def check_extensions_list(self, extensions):
ext_name, build_info = ext
log.warn("old-style (ext_name, build_info) tuple found in "
- "ext_modules for extension '%s'"
+ "ext_modules for extension '%s' "
"-- please convert to Extension instance", ext_name)
if not (isinstance(ext_name, str) and
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index e805a75fbd93..416da1a80d9c 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -2209,8 +2209,8 @@ def get_section(value):
digits += value[0]
value = value[1:]
if digits[0] == '0' and digits != '0':
- section.defects.append(errors.InvalidHeaderError("section number"
- "has an invalid leading 0"))
+ section.defects.append(errors.InvalidHeaderError(
+ "section number has an invalid leading 0"))
section.number = int(digits)
section.append(ValueTerminal(digits, 'digits'))
return section, value
diff --git a/Lib/idlelib/hyperparser.py b/Lib/idlelib/hyperparser.py
index 7581fe274b21..7e7e0ae80247 100644
--- a/Lib/idlelib/hyperparser.py
+++ b/Lib/idlelib/hyperparser.py
@@ -224,7 +224,7 @@ def get_expression(self):
given index, which is empty if there is no real one.
"""
if not self.is_in_code():
- raise ValueError("get_expression should only be called"
+ raise ValueError("get_expression should only be called "
"if index is inside a code.")
rawtext = self.rawtext
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index 8c1c24d070cc..583e607b767e 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -117,7 +117,7 @@ def _wrapper(parent): # htest #
"font face of the text in the area below it.\nIn the "
"'Highlighting' tab, try different color schemes. Clicking "
"items in the sample program should update the choices above it."
- "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings"
+ "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings "
"of interest."
"\n[Ok] to close the dialog.[Apply] to apply the settings and "
"and [Cancel] to revert all changes.\nRe-run the test to ensure "
@@ -152,7 +152,7 @@ def _wrapper(parent): # htest #
'msg': "Test for different key modifier sequences.\n"
" is invalid.\n"
"No modifier key is invalid.\n"
- "Shift key with [a-z],[0-9], function key, move key, tab, space"
+ "Shift key with [a-z],[0-9], function key, move key, tab, space "
"is invalid.\nNo validity checking if advanced key binding "
"entry is used."
}
@@ -234,7 +234,7 @@ def _wrapper(parent): # htest #
'file': 'percolator',
'kwds': {},
'msg': "There are two tracers which can be toggled using a checkbox.\n"
- "Toggling a tracer 'on' by checking it should print tracer"
+ "Toggling a tracer 'on' by checking it should print tracer "
"output to the console or to the IDLE shell.\n"
"If both the tracers are 'on', the output from the tracer which "
"was switched 'on' later, should be printed first\n"
@@ -335,7 +335,7 @@ def _wrapper(parent): # htest #
_widget_redirector_spec = {
'file': 'redirector',
'kwds': {},
- 'msg': "Every text insert should be printed to the console."
+ 'msg': "Every text insert should be printed to the console "
"or the IDLE shell."
}
diff --git a/Lib/idlelib/idle_test/mock_tk.py b/Lib/idlelib/idle_test/mock_tk.py
index 6e351297d75d..a54f51f1949c 100644
--- a/Lib/idlelib/idle_test/mock_tk.py
+++ b/Lib/idlelib/idle_test/mock_tk.py
@@ -260,7 +260,7 @@ def compare(self, index1, op, index2):
elif op == '!=':
return line1 != line2 or char1 != char2
else:
- raise TclError('''bad comparison operator "%s":'''
+ raise TclError('''bad comparison operator "%s": '''
'''must be <, <=, ==, >=, >, or !=''' % op)
# The following Text methods normally do something and return None.
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
index dbdd5bf64192..4b2d3de6d96f 100644
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -66,7 +66,7 @@ def find_module(self, fullname, path):
"""
warnings.warn("MetaPathFinder.find_module() is deprecated since Python "
- "3.4 in favor of MetaPathFinder.find_spec()"
+ "3.4 in favor of MetaPathFinder.find_spec() "
"(available since 3.4)",
DeprecationWarning,
stacklevel=2)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index dafcf004c095..e2a4f2fa6d2f 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1607,7 +1607,7 @@ def test_envar_good_path_empty_string(self):
@unittest.skipIf(sys.flags.ignore_environment, '-E was given')
def test_envar_unimportable(self):
for envar in (
- '.', '..', '.foo', 'foo.', '.int', 'int.'
+ '.', '..', '.foo', 'foo.', '.int', 'int.',
'nosuchbuiltin',
'nosuchmodule.nosuchcallable',
):
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 6b45a2433438..6851f84b85a6 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -285,7 +285,7 @@ def test_import(self):
'from sys import stdin)',
'from sys import stdin, stdout,\nstderr',
'from sys import stdin si',
- 'from sys import stdin,'
+ 'from sys import stdin,',
'from sys import (*)',
'from sys import (stdin,, stdout, stderr)',
'from sys import (stdin, stdout),',
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 58bde54b0a88..1f37b5372a3e 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1172,10 +1172,10 @@ def test_wide_char_separator_decimal_point(self):
decimal_point = locale.localeconv()['decimal_point']
thousands_sep = locale.localeconv()['thousands_sep']
if decimal_point != '\u066b':
- self.skipTest('inappropriate decimal point separator'
+ self.skipTest('inappropriate decimal point separator '
'({!a} not {!a})'.format(decimal_point, '\u066b'))
if thousands_sep != '\u066c':
- self.skipTest('inappropriate thousands separator'
+ self.skipTest('inappropriate thousands separator '
'({!a} not {!a})'.format(thousands_sep, '\u066c'))
self.assertEqual(format(Decimal('100000000.123'), 'n'),
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 968725901f22..8dbea3325d9b 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -174,12 +174,10 @@ def test_iso2time_garbage(self):
'1980-01-01 00:61:00',
'01-01-1980 00:00:62',
'01-01-1980T00:00:62',
- '19800101T250000Z'
- '1980-01-01 00:00:00 -2500',
+ '19800101T250000Z',
]:
self.assertIsNone(iso2time(test),
- "iso2time(%s) is not None\n"
- "iso2time(test) %s" % (test, iso2time(test)))
+ "iso2time(%r)" % test)
class HeaderTests(unittest.TestCase):
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index ce1584748d7e..94c96a941b12 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -39,7 +39,7 @@ def assert_iterators_equal(self, xs, ys, test_id, limit=None):
self.fail('{}: unexpected excess element {} at '
'position {}'.format(test_id, x, i))
else:
- self.fail('{}: wrong element at position {};'
+ self.fail('{}: wrong element at position {}; '
'expected {}, got {}'.format(test_id, i, y, x))
def test_range(self):
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 07d760bd01fd..fdcf6f219256 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -805,7 +805,7 @@ def _auth_cram_md5(self, arg=None):
try:
user, hashed_pass = logpass.split()
except ValueError as e:
- self.push('535 Splitting response {!r} into user and password'
+ self.push('535 Splitting response {!r} into user and password '
'failed: {}'.format(logpass, e))
return False
valid_hashed_pass = hmac.HMAC(
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index de2773f6aa29..a3358a493e53 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -506,7 +506,7 @@ def test_gregorian_calculation(self):
self.assertTrue(result.tm_year == self.time_tuple.tm_year and
result.tm_mon == self.time_tuple.tm_mon and
result.tm_mday == self.time_tuple.tm_mday,
- "Calculation of Gregorian date failed;"
+ "Calculation of Gregorian date failed; "
"%s-%s-%s != %s-%s-%s" %
(result.tm_year, result.tm_mon, result.tm_mday,
self.time_tuple.tm_year, self.time_tuple.tm_mon,
@@ -518,7 +518,7 @@ def test_day_of_week_calculation(self):
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
self.assertTrue(result.tm_wday == self.time_tuple.tm_wday,
- "Calculation of day of the week failed;"
+ "Calculation of day of the week failed; "
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
if support.is_android:
diff --git a/Lib/trace.py b/Lib/trace.py
index 86b2101763bf..0ed7ba95b520 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -299,7 +299,7 @@ def write_results_file(self, path, lines, lnotab, lines_hit, encoding=None):
try:
outfile = open(path, "w", encoding=encoding)
except OSError as err:
- print(("trace: Could not open %r for writing: %s"
+ print(("trace: Could not open %r for writing: %s "
"- skipping" % (path, err)), file=sys.stderr)
return 0, 0
@@ -644,7 +644,7 @@ def main():
grp = parser.add_argument_group('Filters',
'Can be specified multiple times')
grp.add_argument('--ignore-module', action='append', default=[],
- help='Ignore the given module(s) and its submodules'
+ help='Ignore the given module(s) and its submodules '
'(if it is a package). Accepts comma separated list of '
'module names.')
grp.add_argument('--ignore-dir', action='append', default=[],
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 1977b870834b..a9c82dcb5d3e 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1772,7 +1772,7 @@ def method(self, *args, **kw):
_unsupported_magics = {
'__getattr__', '__setattr__',
- '__init__', '__new__', '__prepare__'
+ '__init__', '__new__', '__prepare__',
'__instancecheck__', '__subclasscheck__',
'__del__'
}
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index bc4caa02d5f1..2db95b45345b 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -3446,7 +3446,7 @@ tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt)
return result;
Inconsistent:
- PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave"
+ PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave "
"inconsistent results; cannot convert");
/* fall through to failure */
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index be427772817a..8924834eb81c 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1313,7 +1313,7 @@ _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
/* Check if something is in the read buffer */
if (self->decoded_chars != NULL) {
if (encoding != Py_None || errors != Py_None || newline_obj != NULL) {
- _unsupported("It is not possible to set the encoding or newline"
+ _unsupported("It is not possible to set the encoding or newline "
"of stream after the first read");
return NULL;
}
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 0e3bd225dbd8..2166d296abe4 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4612,7 +4612,7 @@ Pickler_set_memo(PicklerObject *self, PyObject *obj)
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be a PicklerMemoProxy object"
+ "'memo' attribute must be a PicklerMemoProxy object "
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
@@ -7048,7 +7048,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be an UnpicklerMemoProxy object"
+ "'memo' attribute must be an UnpicklerMemoProxy object "
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
diff --git a/Python/import.c b/Python/import.c
index 67911ff0e41b..c0ea968fb8b0 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -839,7 +839,7 @@ remove_module(PyObject *name)
if (!PyMapping_HasKey(modules, name)) {
return;
}
- Py_FatalError("import: deleting existing key in"
+ Py_FatalError("import: deleting existing key in "
"sys.modules failed");
}
}
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index 9c1e9fe8d8c4..5565c210dabb 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -1806,7 +1806,7 @@ def finalize(self):
print('', file=fp)
print('', file=fp)
print('', file=fp)
- print('', file=fp)
print('', file=fp)
print('', file=fp)
@@ -1831,7 +1831,7 @@ def finalize(self):
print('', file=fp)
print('', file=fp)
print('', file=fp)
- print('', file=fp)
print('', file=fp)
print('', file=fp)
From webhook-mailer at python.org Mon Nov 5 09:53:10 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Mon, 05 Nov 2018 14:53:10 -0000
Subject: [Python-checkins] bpo-35133: Fix mistakes when concatenate string
literals on different lines. (GH-10284)
Message-ID:
https://github.com/python/cpython/commit/7beb8c54ede7669a59bb9b912ba0ffd8aa3998c6
commit: 7beb8c54ede7669a59bb9b912ba0ffd8aa3998c6
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T06:52:58-08:00
summary:
bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings.
(cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d)
Co-authored-by: Serhiy Storchaka
files:
M Lib/_pydecimal.py
M Lib/concurrent/futures/thread.py
M Lib/distutils/command/bdist_dumb.py
M Lib/distutils/command/bdist_msi.py
M Lib/distutils/command/bdist_rpm.py
M Lib/distutils/command/bdist_wininst.py
M Lib/distutils/command/build_ext.py
M Lib/email/_header_value_parser.py
M Lib/idlelib/hyperparser.py
M Lib/idlelib/idle_test/htest.py
M Lib/idlelib/idle_test/mock_tk.py
M Lib/importlib/abc.py
M Lib/test/test_builtin.py
M Lib/test/test_compile.py
M Lib/test/test_decimal.py
M Lib/test/test_http_cookiejar.py
M Lib/test/test_range.py
M Lib/test/test_smtplib.py
M Lib/test/test_strptime.py
M Lib/trace.py
M Lib/unittest/mock.py
M Modules/_datetimemodule.c
M Modules/_io/textio.c
M Modules/_pickle.c
M Python/import.c
M Tools/scripts/texi2html.py
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
index 359690003fe1..44ea5b41b2a1 100644
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -2021,7 +2021,7 @@ def _power_modulo(self, other, modulo, context=None):
if not other and not self:
return context._raise_error(InvalidOperation,
'at least one of pow() 1st argument '
- 'and 2nd argument must be nonzero ;'
+ 'and 2nd argument must be nonzero; '
'0**0 is not defined')
# compute sign of result
diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py
index b65dee11f727..78359711d5d9 100644
--- a/Lib/concurrent/futures/thread.py
+++ b/Lib/concurrent/futures/thread.py
@@ -150,7 +150,7 @@ def submit(self, fn, *args, **kwargs):
if self._shutdown:
raise RuntimeError('cannot schedule new futures after shutdown')
if _shutdown:
- raise RuntimeError('cannot schedule new futures after'
+ raise RuntimeError('cannot schedule new futures after '
'interpreter shutdown')
f = _base.Future()
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index e9274d925afa..f0d6b5b8cd8a 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -32,7 +32,7 @@ class bdist_dumb(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('relative', None,
- "build the archive using relative paths"
+ "build the archive using relative paths "
"(default: false)"),
('owner=', 'u',
"Owner name used when creating a tar file"
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index a4bd5a589d38..80104c372d9a 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -98,14 +98,14 @@ class bdist_msi(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index ac4621791d56..02f10dd89d91 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -58,7 +58,7 @@ class bdist_rpm(Command):
"RPM \"vendor\" (eg. \"Joe Blow \") "
"[default: maintainer or author from setup script]"),
('packager=', None,
- "RPM packager (eg. \"Jane Doe \")"
+ "RPM packager (eg. \"Jane Doe \") "
"[default: vendor]"),
('doc-files=', None,
"list of documentation files (space or comma-separated)"),
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index 0871a4f7d6b2..fde56754e891 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -29,7 +29,7 @@ class bdist_wininst(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
@@ -40,7 +40,7 @@ class bdist_wininst(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 8fad9cdc2b47..158465d2338c 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -365,7 +365,7 @@ def check_extensions_list(self, extensions):
ext_name, build_info = ext
log.warn("old-style (ext_name, build_info) tuple found in "
- "ext_modules for extension '%s'"
+ "ext_modules for extension '%s' "
"-- please convert to Extension instance", ext_name)
if not (isinstance(ext_name, str) and
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index e805a75fbd93..416da1a80d9c 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -2209,8 +2209,8 @@ def get_section(value):
digits += value[0]
value = value[1:]
if digits[0] == '0' and digits != '0':
- section.defects.append(errors.InvalidHeaderError("section number"
- "has an invalid leading 0"))
+ section.defects.append(errors.InvalidHeaderError(
+ "section number has an invalid leading 0"))
section.number = int(digits)
section.append(ValueTerminal(digits, 'digits'))
return section, value
diff --git a/Lib/idlelib/hyperparser.py b/Lib/idlelib/hyperparser.py
index 7581fe274b21..7e7e0ae80247 100644
--- a/Lib/idlelib/hyperparser.py
+++ b/Lib/idlelib/hyperparser.py
@@ -224,7 +224,7 @@ def get_expression(self):
given index, which is empty if there is no real one.
"""
if not self.is_in_code():
- raise ValueError("get_expression should only be called"
+ raise ValueError("get_expression should only be called "
"if index is inside a code.")
rawtext = self.rawtext
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index 8c1c24d070cc..583e607b767e 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -117,7 +117,7 @@ def _wrapper(parent): # htest #
"font face of the text in the area below it.\nIn the "
"'Highlighting' tab, try different color schemes. Clicking "
"items in the sample program should update the choices above it."
- "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings"
+ "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings "
"of interest."
"\n[Ok] to close the dialog.[Apply] to apply the settings and "
"and [Cancel] to revert all changes.\nRe-run the test to ensure "
@@ -152,7 +152,7 @@ def _wrapper(parent): # htest #
'msg': "Test for different key modifier sequences.\n"
" is invalid.\n"
"No modifier key is invalid.\n"
- "Shift key with [a-z],[0-9], function key, move key, tab, space"
+ "Shift key with [a-z],[0-9], function key, move key, tab, space "
"is invalid.\nNo validity checking if advanced key binding "
"entry is used."
}
@@ -234,7 +234,7 @@ def _wrapper(parent): # htest #
'file': 'percolator',
'kwds': {},
'msg': "There are two tracers which can be toggled using a checkbox.\n"
- "Toggling a tracer 'on' by checking it should print tracer"
+ "Toggling a tracer 'on' by checking it should print tracer "
"output to the console or to the IDLE shell.\n"
"If both the tracers are 'on', the output from the tracer which "
"was switched 'on' later, should be printed first\n"
@@ -335,7 +335,7 @@ def _wrapper(parent): # htest #
_widget_redirector_spec = {
'file': 'redirector',
'kwds': {},
- 'msg': "Every text insert should be printed to the console."
+ 'msg': "Every text insert should be printed to the console "
"or the IDLE shell."
}
diff --git a/Lib/idlelib/idle_test/mock_tk.py b/Lib/idlelib/idle_test/mock_tk.py
index 6e351297d75d..a54f51f1949c 100644
--- a/Lib/idlelib/idle_test/mock_tk.py
+++ b/Lib/idlelib/idle_test/mock_tk.py
@@ -260,7 +260,7 @@ def compare(self, index1, op, index2):
elif op == '!=':
return line1 != line2 or char1 != char2
else:
- raise TclError('''bad comparison operator "%s":'''
+ raise TclError('''bad comparison operator "%s": '''
'''must be <, <=, ==, >=, >, or !=''' % op)
# The following Text methods normally do something and return None.
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
index dbdd5bf64192..4b2d3de6d96f 100644
--- a/Lib/importlib/abc.py
+++ b/Lib/importlib/abc.py
@@ -66,7 +66,7 @@ def find_module(self, fullname, path):
"""
warnings.warn("MetaPathFinder.find_module() is deprecated since Python "
- "3.4 in favor of MetaPathFinder.find_spec()"
+ "3.4 in favor of MetaPathFinder.find_spec() "
"(available since 3.4)",
DeprecationWarning,
stacklevel=2)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index e7202cd70c9c..7c9768a337bb 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1600,7 +1600,7 @@ def test_envar_good_path_empty_string(self):
@unittest.skipIf(sys.flags.ignore_environment, '-E was given')
def test_envar_unimportable(self):
for envar in (
- '.', '..', '.foo', 'foo.', '.int', 'int.'
+ '.', '..', '.foo', 'foo.', '.int', 'int.',
'nosuchbuiltin',
'nosuchmodule.nosuchcallable',
):
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index acebdbdc4636..d8a57e5e0925 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -285,7 +285,7 @@ def test_import(self):
'from sys import stdin)',
'from sys import stdin, stdout,\nstderr',
'from sys import stdin si',
- 'from sys import stdin,'
+ 'from sys import stdin,',
'from sys import (*)',
'from sys import (stdin,, stdout, stderr)',
'from sys import (stdin, stdout),',
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 58bde54b0a88..1f37b5372a3e 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1172,10 +1172,10 @@ def test_wide_char_separator_decimal_point(self):
decimal_point = locale.localeconv()['decimal_point']
thousands_sep = locale.localeconv()['thousands_sep']
if decimal_point != '\u066b':
- self.skipTest('inappropriate decimal point separator'
+ self.skipTest('inappropriate decimal point separator '
'({!a} not {!a})'.format(decimal_point, '\u066b'))
if thousands_sep != '\u066c':
- self.skipTest('inappropriate thousands separator'
+ self.skipTest('inappropriate thousands separator '
'({!a} not {!a})'.format(thousands_sep, '\u066c'))
self.assertEqual(format(Decimal('100000000.123'), 'n'),
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 6fee4df10a40..abc625d672a7 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -174,12 +174,10 @@ def test_iso2time_garbage(self):
'1980-01-01 00:61:00',
'01-01-1980 00:00:62',
'01-01-1980T00:00:62',
- '19800101T250000Z'
- '1980-01-01 00:00:00 -2500',
+ '19800101T250000Z',
]:
self.assertIsNone(iso2time(test),
- "iso2time(%s) is not None\n"
- "iso2time(test) %s" % (test, iso2time(test)))
+ "iso2time(%r)" % test)
class HeaderTests(unittest.TestCase):
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index ce1584748d7e..94c96a941b12 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -39,7 +39,7 @@ def assert_iterators_equal(self, xs, ys, test_id, limit=None):
self.fail('{}: unexpected excess element {} at '
'position {}'.format(test_id, x, i))
else:
- self.fail('{}: wrong element at position {};'
+ self.fail('{}: wrong element at position {}; '
'expected {}, got {}'.format(test_id, i, y, x))
def test_range(self):
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 8a29e98a4f30..b4149d3ef007 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -770,7 +770,7 @@ def _auth_cram_md5(self, arg=None):
try:
user, hashed_pass = logpass.split()
except ValueError as e:
- self.push('535 Splitting response {!r} into user and password'
+ self.push('535 Splitting response {!r} into user and password '
'failed: {}'.format(logpass, e))
return False
valid_hashed_pass = hmac.HMAC(
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index de2773f6aa29..a3358a493e53 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -506,7 +506,7 @@ def test_gregorian_calculation(self):
self.assertTrue(result.tm_year == self.time_tuple.tm_year and
result.tm_mon == self.time_tuple.tm_mon and
result.tm_mday == self.time_tuple.tm_mday,
- "Calculation of Gregorian date failed;"
+ "Calculation of Gregorian date failed; "
"%s-%s-%s != %s-%s-%s" %
(result.tm_year, result.tm_mon, result.tm_mday,
self.time_tuple.tm_year, self.time_tuple.tm_mon,
@@ -518,7 +518,7 @@ def test_day_of_week_calculation(self):
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
self.assertTrue(result.tm_wday == self.time_tuple.tm_wday,
- "Calculation of day of the week failed;"
+ "Calculation of day of the week failed; "
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
if support.is_android:
diff --git a/Lib/trace.py b/Lib/trace.py
index 86b2101763bf..0ed7ba95b520 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -299,7 +299,7 @@ def write_results_file(self, path, lines, lnotab, lines_hit, encoding=None):
try:
outfile = open(path, "w", encoding=encoding)
except OSError as err:
- print(("trace: Could not open %r for writing: %s"
+ print(("trace: Could not open %r for writing: %s "
"- skipping" % (path, err)), file=sys.stderr)
return 0, 0
@@ -644,7 +644,7 @@ def main():
grp = parser.add_argument_group('Filters',
'Can be specified multiple times')
grp.add_argument('--ignore-module', action='append', default=[],
- help='Ignore the given module(s) and its submodules'
+ help='Ignore the given module(s) and its submodules '
'(if it is a package). Accepts comma separated list of '
'module names.')
grp.add_argument('--ignore-dir', action='append', default=[],
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 1a6c251d2cf7..b0c03c03bd6f 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1749,7 +1749,7 @@ def method(self, *args, **kw):
_unsupported_magics = {
'__getattr__', '__setattr__',
- '__init__', '__new__', '__prepare__'
+ '__init__', '__new__', '__prepare__',
'__instancecheck__', '__subclasscheck__',
'__del__'
}
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index f53880808d21..1f15367d3fa3 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -3443,7 +3443,7 @@ tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt)
return result;
Inconsistent:
- PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave"
+ PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave "
"inconsistent results; cannot convert");
/* fall through to failure */
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 73d1b2e8a23b..9d0d9cac40db 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1313,7 +1313,7 @@ _io_TextIOWrapper_reconfigure_impl(textio *self, PyObject *encoding,
/* Check if something is in the read buffer */
if (self->decoded_chars != NULL) {
if (encoding != Py_None || errors != Py_None || newline_obj != NULL) {
- _unsupported("It is not possible to set the encoding or newline"
+ _unsupported("It is not possible to set the encoding or newline "
"of stream after the first read");
return NULL;
}
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index ba8962d686de..03f575e4621c 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4614,7 +4614,7 @@ Pickler_set_memo(PicklerObject *self, PyObject *obj)
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be a PicklerMemoProxy object"
+ "'memo' attribute must be a PicklerMemoProxy object "
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
@@ -7060,7 +7060,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be an UnpicklerMemoProxy object"
+ "'memo' attribute must be an UnpicklerMemoProxy object "
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
diff --git a/Python/import.c b/Python/import.c
index 5d1794720cfc..709fc4324e6f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -833,7 +833,7 @@ remove_module(PyObject *name)
if (!PyMapping_HasKey(modules, name)) {
return;
}
- Py_FatalError("import: deleting existing key in"
+ Py_FatalError("import: deleting existing key in "
"sys.modules failed");
}
}
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index 9c1e9fe8d8c4..5565c210dabb 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -1806,7 +1806,7 @@ def finalize(self):
print('', file=fp)
print('', file=fp)
print('', file=fp)
- print('', file=fp)
print('', file=fp)
print('', file=fp)
@@ -1831,7 +1831,7 @@ def finalize(self):
print('', file=fp)
print('', file=fp)
print('', file=fp)
- print('', file=fp)
print('', file=fp)
print('', file=fp)
From webhook-mailer at python.org Mon Nov 5 10:13:55 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 15:13:55 -0000
Subject: [Python-checkins] [3.6] bpo-35133: Fix mistakes when concatenate
string literals on different lines. (GH-10284) (GH-10335)
Message-ID:
https://github.com/python/cpython/commit/7054e5c80b6e98cd44e22d1bc2d7f0a94343089d
commit: 7054e5c80b6e98cd44e22d1bc2d7f0a94343089d
branch: 3.6
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-05T17:13:50+02:00
summary:
[3.6] bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284) (GH-10335)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings..
(cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d)
files:
M Lib/_pydecimal.py
M Lib/distutils/command/bdist_dumb.py
M Lib/distutils/command/bdist_msi.py
M Lib/distutils/command/bdist_rpm.py
M Lib/distutils/command/bdist_wininst.py
M Lib/distutils/command/build_ext.py
M Lib/email/_header_value_parser.py
M Lib/idlelib/hyperparser.py
M Lib/idlelib/idle_test/htest.py
M Lib/idlelib/idle_test/mock_tk.py
M Lib/test/test_compile.py
M Lib/test/test_decimal.py
M Lib/test/test_http_cookiejar.py
M Lib/test/test_range.py
M Lib/test/test_smtplib.py
M Lib/test/test_strptime.py
M Lib/trace.py
M Lib/unittest/mock.py
M Modules/_datetimemodule.c
M Modules/_pickle.c
M Python/import.c
M Tools/scripts/texi2html.py
diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py
index 0b40928ff8d1..e7df67dc9b9d 100644
--- a/Lib/_pydecimal.py
+++ b/Lib/_pydecimal.py
@@ -2062,7 +2062,7 @@ def _power_modulo(self, other, modulo, context=None):
if not other and not self:
return context._raise_error(InvalidOperation,
'at least one of pow() 1st argument '
- 'and 2nd argument must be nonzero ;'
+ 'and 2nd argument must be nonzero; '
'0**0 is not defined')
# compute sign of result
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index e9274d925afa..f0d6b5b8cd8a 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -32,7 +32,7 @@ class bdist_dumb(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('relative', None,
- "build the archive using relative paths"
+ "build the archive using relative paths "
"(default: false)"),
('owner=', 'u',
"Owner name used when creating a tar file"
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index a4bd5a589d38..80104c372d9a 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -98,14 +98,14 @@ class bdist_msi(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index ac4621791d56..02f10dd89d91 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -58,7 +58,7 @@ class bdist_rpm(Command):
"RPM \"vendor\" (eg. \"Joe Blow \") "
"[default: maintainer or author from setup script]"),
('packager=', None,
- "RPM packager (eg. \"Jane Doe \")"
+ "RPM packager (eg. \"Jane Doe \") "
"[default: vendor]"),
('doc-files=', None,
"list of documentation files (space or comma-separated)"),
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index 0871a4f7d6b2..fde56754e891 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -29,7 +29,7 @@ class bdist_wininst(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
@@ -40,7 +40,7 @@ class bdist_wininst(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 74de782d8a66..8ed4065bb5f0 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -365,7 +365,7 @@ def check_extensions_list(self, extensions):
ext_name, build_info = ext
log.warn("old-style (ext_name, build_info) tuple found in "
- "ext_modules for extension '%s'"
+ "ext_modules for extension '%s' "
"-- please convert to Extension instance", ext_name)
if not (isinstance(ext_name, str) and
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index de7ab5d12e78..1fb8cb448a01 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -2210,8 +2210,8 @@ def get_section(value):
digits += value[0]
value = value[1:]
if digits[0] == '0' and digits != '0':
- section.defects.append(errors.InvalidHeaderError("section number"
- "has an invalid leading 0"))
+ section.defects.append(errors.InvalidHeaderError(
+ "section number has an invalid leading 0"))
section.number = int(digits)
section.append(ValueTerminal(digits, 'digits'))
return section, value
diff --git a/Lib/idlelib/hyperparser.py b/Lib/idlelib/hyperparser.py
index 7581fe274b21..7e7e0ae80247 100644
--- a/Lib/idlelib/hyperparser.py
+++ b/Lib/idlelib/hyperparser.py
@@ -224,7 +224,7 @@ def get_expression(self):
given index, which is empty if there is no real one.
"""
if not self.is_in_code():
- raise ValueError("get_expression should only be called"
+ raise ValueError("get_expression should only be called "
"if index is inside a code.")
rawtext = self.rawtext
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index 8c1c24d070cc..583e607b767e 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -117,7 +117,7 @@ def _wrapper(parent): # htest #
"font face of the text in the area below it.\nIn the "
"'Highlighting' tab, try different color schemes. Clicking "
"items in the sample program should update the choices above it."
- "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings"
+ "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings "
"of interest."
"\n[Ok] to close the dialog.[Apply] to apply the settings and "
"and [Cancel] to revert all changes.\nRe-run the test to ensure "
@@ -152,7 +152,7 @@ def _wrapper(parent): # htest #
'msg': "Test for different key modifier sequences.\n"
" is invalid.\n"
"No modifier key is invalid.\n"
- "Shift key with [a-z],[0-9], function key, move key, tab, space"
+ "Shift key with [a-z],[0-9], function key, move key, tab, space "
"is invalid.\nNo validity checking if advanced key binding "
"entry is used."
}
@@ -234,7 +234,7 @@ def _wrapper(parent): # htest #
'file': 'percolator',
'kwds': {},
'msg': "There are two tracers which can be toggled using a checkbox.\n"
- "Toggling a tracer 'on' by checking it should print tracer"
+ "Toggling a tracer 'on' by checking it should print tracer "
"output to the console or to the IDLE shell.\n"
"If both the tracers are 'on', the output from the tracer which "
"was switched 'on' later, should be printed first\n"
@@ -335,7 +335,7 @@ def _wrapper(parent): # htest #
_widget_redirector_spec = {
'file': 'redirector',
'kwds': {},
- 'msg': "Every text insert should be printed to the console."
+ 'msg': "Every text insert should be printed to the console "
"or the IDLE shell."
}
diff --git a/Lib/idlelib/idle_test/mock_tk.py b/Lib/idlelib/idle_test/mock_tk.py
index 6e351297d75d..a54f51f1949c 100644
--- a/Lib/idlelib/idle_test/mock_tk.py
+++ b/Lib/idlelib/idle_test/mock_tk.py
@@ -260,7 +260,7 @@ def compare(self, index1, op, index2):
elif op == '!=':
return line1 != line2 or char1 != char2
else:
- raise TclError('''bad comparison operator "%s":'''
+ raise TclError('''bad comparison operator "%s": '''
'''must be <, <=, ==, >=, >, or !=''' % op)
# The following Text methods normally do something and return None.
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index c9812e46b486..745ce029aa57 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -285,7 +285,7 @@ def test_import(self):
'from sys import stdin)',
'from sys import stdin, stdout,\nstderr',
'from sys import stdin si',
- 'from sys import stdin,'
+ 'from sys import stdin,',
'from sys import (*)',
'from sys import (stdin,, stdout, stderr)',
'from sys import (stdin, stdout),',
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 45d80cec810f..8808a670f939 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1178,10 +1178,10 @@ def test_wide_char_separator_decimal_point(self):
decimal_point = locale.localeconv()['decimal_point']
thousands_sep = locale.localeconv()['thousands_sep']
if decimal_point != '\u066b':
- self.skipTest('inappropriate decimal point separator'
+ self.skipTest('inappropriate decimal point separator '
'({!a} not {!a})'.format(decimal_point, '\u066b'))
if thousands_sep != '\u066c':
- self.skipTest('inappropriate thousands separator'
+ self.skipTest('inappropriate thousands separator '
'({!a} not {!a})'.format(thousands_sep, '\u066c'))
self.assertEqual(format(Decimal('100000000.123'), 'n'),
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 6fee4df10a40..abc625d672a7 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -174,12 +174,10 @@ def test_iso2time_garbage(self):
'1980-01-01 00:61:00',
'01-01-1980 00:00:62',
'01-01-1980T00:00:62',
- '19800101T250000Z'
- '1980-01-01 00:00:00 -2500',
+ '19800101T250000Z',
]:
self.assertIsNone(iso2time(test),
- "iso2time(%s) is not None\n"
- "iso2time(test) %s" % (test, iso2time(test)))
+ "iso2time(%r)" % test)
class HeaderTests(unittest.TestCase):
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
index 679759ec6d67..b6f948dc6a8f 100644
--- a/Lib/test/test_range.py
+++ b/Lib/test/test_range.py
@@ -40,7 +40,7 @@ def assert_iterators_equal(self, xs, ys, test_id, limit=None):
self.fail('{}: unexpected excess element {} at '
'position {}'.format(test_id, x, i))
else:
- self.fail('{}: wrong element at position {};'
+ self.fail('{}: wrong element at position {}; '
'expected {}, got {}'.format(test_id, i, y, x))
def test_range(self):
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 18110191dc3b..87047514e7aa 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -767,7 +767,7 @@ def _auth_cram_md5(self, arg=None):
try:
user, hashed_pass = logpass.split()
except ValueError as e:
- self.push('535 Splitting response {!r} into user and password'
+ self.push('535 Splitting response {!r} into user and password '
'failed: {}'.format(logpass, e))
return False
valid_hashed_pass = hmac.HMAC(
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 2cf0926239c0..1438487161f9 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -457,7 +457,7 @@ def test_gregorian_calculation(self):
self.assertTrue(result.tm_year == self.time_tuple.tm_year and
result.tm_mon == self.time_tuple.tm_mon and
result.tm_mday == self.time_tuple.tm_mday,
- "Calculation of Gregorian date failed;"
+ "Calculation of Gregorian date failed; "
"%s-%s-%s != %s-%s-%s" %
(result.tm_year, result.tm_mon, result.tm_mday,
self.time_tuple.tm_year, self.time_tuple.tm_mon,
@@ -469,7 +469,7 @@ def test_day_of_week_calculation(self):
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
self.assertTrue(result.tm_wday == self.time_tuple.tm_wday,
- "Calculation of day of the week failed;"
+ "Calculation of day of the week failed; "
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
if support.is_android:
diff --git a/Lib/trace.py b/Lib/trace.py
index d171577e3991..e5fa94fc948f 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -313,7 +313,7 @@ def write_results_file(self, path, lines, lnotab, lines_hit, encoding=None):
try:
outfile = open(path, "w", encoding=encoding)
except OSError as err:
- print(("trace: Could not open %r for writing: %s"
+ print(("trace: Could not open %r for writing: %s "
"- skipping" % (path, err)), file=sys.stderr)
return 0, 0
@@ -655,7 +655,7 @@ def main():
grp = parser.add_argument_group('Filters',
'Can be specified multiple times')
grp.add_argument('--ignore-module', action='append', default=[],
- help='Ignore the given module(s) and its submodules'
+ help='Ignore the given module(s) and its submodules '
'(if it is a package). Accepts comma separated list of '
'module names.')
grp.add_argument('--ignore-dir', action='append', default=[],
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 86183adc1905..31b198516161 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1737,7 +1737,7 @@ def method(self, *args, **kw):
_unsupported_magics = {
'__getattr__', '__setattr__',
- '__init__', '__new__', '__prepare__'
+ '__init__', '__new__', '__prepare__',
'__instancecheck__', '__subclasscheck__',
'__del__'
}
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index afc865e466de..b2e0176b3232 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -3158,7 +3158,7 @@ tzinfo_fromutc(PyDateTime_TZInfo *self, PyObject *dt)
return result;
Inconsistent:
- PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave"
+ PyErr_SetString(PyExc_ValueError, "fromutc: tz.dst() gave "
"inconsistent results; cannot convert");
/* fall through to failure */
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 0a7e20e10592..6830d93f503e 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4527,7 +4527,7 @@ Pickler_set_memo(PicklerObject *self, PyObject *obj)
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be a PicklerMemoProxy object"
+ "'memo' attribute must be a PicklerMemoProxy object "
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
@@ -6969,7 +6969,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
}
else {
PyErr_Format(PyExc_TypeError,
- "'memo' attribute must be an UnpicklerMemoProxy object"
+ "'memo' attribute must be an UnpicklerMemoProxy object "
"or dict, not %.200s", Py_TYPE(obj)->tp_name);
return -1;
}
diff --git a/Python/import.c b/Python/import.c
index fa0a9e1f2a43..db1650a9ddd2 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -715,7 +715,7 @@ remove_module(PyObject *name)
if (PyDict_GetItem(modules, name) == NULL)
return;
if (PyDict_DelItem(modules, name) < 0)
- Py_FatalError("import: deleting existing key in"
+ Py_FatalError("import: deleting existing key in "
"sys.modules failed");
}
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index 9c1e9fe8d8c4..5565c210dabb 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -1806,7 +1806,7 @@ def finalize(self):
print('', file=fp)
print('', file=fp)
print('', file=fp)
- print('', file=fp)
print('', file=fp)
print('', file=fp)
@@ -1831,7 +1831,7 @@ def finalize(self):
print('', file=fp)
print('', file=fp)
print('', file=fp)
- print('', file=fp)
print('', file=fp)
print('', file=fp)
From webhook-mailer at python.org Mon Nov 5 10:47:30 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 15:47:30 -0000
Subject: [Python-checkins] bpo-35167: Specify program for gzip and json.tool
command line options. (GH-10332)
Message-ID:
https://github.com/python/cpython/commit/083a7a172b8c8888252d72031f21dcfea3c0d73f
commit: 083a7a172b8c8888252d72031f21dcfea3c0d73f
branch: master
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-05T17:47:27+02:00
summary:
bpo-35167: Specify program for gzip and json.tool command line options. (GH-10332)
files:
M Doc/library/gzip.rst
M Doc/library/json.rst
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
index a93f37743854..a57307b0e499 100644
--- a/Doc/library/gzip.rst
+++ b/Doc/library/gzip.rst
@@ -211,6 +211,9 @@ Example of how to GZIP compress a binary string::
The basic data compression module needed to support the :program:`gzip` file
format.
+
+.. program:: gzip
+
Command Line Interface
----------------------
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 8ce493d63995..510e30733fed 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -648,7 +648,9 @@ when serializing Python :class:`int` values of extremely large magnitude, or
when serializing instances of "exotic" numerical types such as
:class:`decimal.Decimal`.
+
.. _json-commandline:
+.. program:: json.tool
Command Line Interface
----------------------
@@ -680,6 +682,7 @@ specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively:
:option:`--sort-keys` option to sort the output of dictionaries
alphabetically by key.
+
Command line options
^^^^^^^^^^^^^^^^^^^^
From webhook-mailer at python.org Mon Nov 5 11:16:30 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 16:16:30 -0000
Subject: [Python-checkins] [2.7] bpo-35133: Fix mistakes when concatenate
string literals on different lines. (GH-10284) (GH-10335) (GH-10336)
Message-ID:
https://github.com/python/cpython/commit/3e3e1a27f769b3385853fbcad6749e71ca7f3ce3
commit: 3e3e1a27f769b3385853fbcad6749e71ca7f3ce3
branch: 2.7
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-05T18:16:26+02:00
summary:
[2.7] bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284) (GH-10335) (GH-10336)
Two kind of mistakes:
1. Missed space. After concatenating there is no space between words.
2. Missed comma. Causes unintentional concatenating in a list of strings.
(cherry picked from commit 34fd4c20198dea6ab2fe8dc6d32d744d9bde868d)
(cherry picked from commit 7054e5c80b6e98cd44e22d1bc2d7f0a94343089d)
files:
M Lib/decimal.py
M Lib/distutils/command/bdist_dumb.py
M Lib/distutils/command/bdist_msi.py
M Lib/distutils/command/bdist_rpm.py
M Lib/distutils/command/bdist_wininst.py
M Lib/distutils/command/build_ext.py
M Lib/idlelib/HyperParser.py
M Lib/idlelib/idle_test/htest.py
M Lib/idlelib/idle_test/mock_tk.py
M Lib/test/test_compile.py
M Lib/test/test_decimal.py
M Lib/test/test_strptime.py
M Lib/trace.py
M Python/import.c
M Tools/scripts/texi2html.py
diff --git a/Lib/decimal.py b/Lib/decimal.py
index e5329dde4946..220fa57ac5be 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -1909,7 +1909,7 @@ def _power_modulo(self, other, modulo, context=None):
if not other and not self:
return context._raise_error(InvalidOperation,
'at least one of pow() 1st argument '
- 'and 2nd argument must be nonzero ;'
+ 'and 2nd argument must be nonzero; '
'0**0 is not defined')
# compute sign of result
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index 2f3c66829a1b..d8e023dd0584 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -35,7 +35,7 @@ class bdist_dumb (Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('relative', None,
- "build the archive using relative paths"
+ "build the archive using relative paths "
"(default: false)"),
('owner=', 'u',
"Owner name used when creating a tar file"
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index 703f873b164e..d2401bc4736a 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -99,14 +99,14 @@ class bdist_msi (Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index 477e0ee064b7..caadf489a938 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -63,7 +63,7 @@ class bdist_rpm (Command):
"RPM \"vendor\" (eg. \"Joe Blow \") "
"[default: maintainer or author from setup script]"),
('packager=', None,
- "RPM packager (eg. \"Jane Doe \")"
+ "RPM packager (eg. \"Jane Doe \") "
"[default: vendor]"),
('doc-files=', None,
"list of documentation files (space or comma-separated)"),
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index aa9383af98b6..a1de52027681 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -35,7 +35,7 @@ class bdist_wininst (Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
- "do not compile .py to .pyo (optimized)"
+ "do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
@@ -46,7 +46,7 @@ class bdist_wininst (Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
- "basename of installation script to be run after"
+ "basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 2c68be39cdf6..86a85c1a0a01 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -366,7 +366,7 @@ def check_extensions_list(self, extensions):
ext_name, build_info = ext
log.warn(("old-style (ext_name, build_info) tuple found in "
- "ext_modules for extension '%s'"
+ "ext_modules for extension '%s' "
"-- please convert to Extension instance" % ext_name))
if not (isinstance(ext_name, str) and
diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py
index 5816d00f45c8..6e45b161a46d 100644
--- a/Lib/idlelib/HyperParser.py
+++ b/Lib/idlelib/HyperParser.py
@@ -167,7 +167,7 @@ def get_expression(self):
given index, which is empty if there is no real one.
"""
if not self.is_in_code():
- raise ValueError("get_expression should only be called"
+ raise ValueError("get_expression should only be called "
"if index is inside a code.")
rawtext = self.rawtext
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py
index f34140921c81..9e2ddd2c19e0 100644
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -112,7 +112,7 @@ def _wrapper(parent): # htest #
"font face of the text in the area below it.\nIn the "
"'Highlighting' tab, try different color schemes. Clicking "
"items in the sample program should update the choices above it."
- "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings"
+ "\nIn the 'Keys', 'General' and 'Extensions' tabs, test settings "
"of interest."
"\n[Ok] to close the dialog.[Apply] to apply the settings and "
"and [Cancel] to revert all changes.\nRe-run the test to ensure "
@@ -171,7 +171,7 @@ def _wrapper(parent): # htest #
'msg': "Test for different key modifier sequences.\n"
" is invalid.\n"
"No modifier key is invalid.\n"
- "Shift key with [a-z],[0-9], function key, move key, tab, space"
+ "Shift key with [a-z],[0-9], function key, move key, tab, space "
"is invalid.\nNo validitity checking if advanced key binding "
"entry is used."
}
@@ -237,7 +237,7 @@ def _wrapper(parent): # htest #
'file': 'Percolator',
'kwds': {},
'msg': "There are two tracers which can be toggled using a checkbox.\n"
- "Toggling a tracer 'on' by checking it should print tracer"
+ "Toggling a tracer 'on' by checking it should print tracer "
"output to the console or to the IDLE shell.\n"
"If both the tracers are 'on', the output from the tracer which "
"was switched 'on' later, should be printed first\n"
@@ -329,7 +329,7 @@ def _wrapper(parent): # htest #
_widget_redirector_spec = {
'file': 'WidgetRedirector',
'kwds': {},
- 'msg': "Every text insert should be printed to the console."
+ 'msg': "Every text insert should be printed to the console "
"or the IDLE shell."
}
diff --git a/Lib/idlelib/idle_test/mock_tk.py b/Lib/idlelib/idle_test/mock_tk.py
index f42a039711b4..56ca87695af6 100644
--- a/Lib/idlelib/idle_test/mock_tk.py
+++ b/Lib/idlelib/idle_test/mock_tk.py
@@ -260,7 +260,7 @@ def compare(self, index1, op, index2):
elif op == '!=':
return line1 != line2 or char1 != char2
else:
- raise TclError('''bad comparison operator "%s":'''
+ raise TclError('''bad comparison operator "%s": '''
'''must be <, <=, ==, >=, >, or !=''' % op)
# The following Text methods normally do something and return None.
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index e954a0ce7461..15a00f3cf7fc 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -392,7 +392,7 @@ def test_import(self):
'from sys import stdin)',
'from sys import stdin, stdout,\nstderr',
'from sys import stdin si',
- 'from sys import stdin,'
+ 'from sys import stdin,',
'from sys import (*)',
'from sys import (stdin,, stdout, stderr)',
'from sys import (stdin, stdout),',
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 14b7f42f5627..f481075cee25 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -914,10 +914,10 @@ def test_wide_char_separator_decimal_point(self):
decimal_point = locale.localeconv()['decimal_point']
thousands_sep = locale.localeconv()['thousands_sep']
if decimal_point != '\xd9\xab':
- self.skipTest('inappropriate decimal point separator'
+ self.skipTest('inappropriate decimal point separator '
'({!r} not {!r})'.format(decimal_point, '\xd9\xab'))
if thousands_sep != '\xd9\xac':
- self.skipTest('inappropriate thousands separator'
+ self.skipTest('inappropriate thousands separator '
'({!r} not {!r})'.format(thousands_sep, '\xd9\xac'))
self.assertEqual(format(Decimal('100000000.123'), 'n'),
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 3d249419517a..48ad5daec402 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -428,7 +428,7 @@ def test_gregorian_calculation(self):
self.assertTrue(result.tm_year == self.time_tuple.tm_year and
result.tm_mon == self.time_tuple.tm_mon and
result.tm_mday == self.time_tuple.tm_mday,
- "Calculation of Gregorian date failed;"
+ "Calculation of Gregorian date failed; "
"%s-%s-%s != %s-%s-%s" %
(result.tm_year, result.tm_mon, result.tm_mday,
self.time_tuple.tm_year, self.time_tuple.tm_mon,
@@ -440,7 +440,7 @@ def test_day_of_week_calculation(self):
result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
format_string)
self.assertTrue(result.tm_wday == self.time_tuple.tm_wday,
- "Calculation of day of the week failed;"
+ "Calculation of day of the week failed; "
"%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
def test_week_of_year_and_day_of_week_calculation(self):
diff --git a/Lib/trace.py b/Lib/trace.py
index 38a13e2a9f0f..96af2603540e 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -360,7 +360,7 @@ def write_results_file(self, path, lines, lnotab, lines_hit):
try:
outfile = open(path, "w")
except IOError, err:
- print >> sys.stderr, ("trace: Could not open %r for writing: %s"
+ print >> sys.stderr, ("trace: Could not open %r for writing: %s "
"- skipping" % (path, err))
return 0, 0
diff --git a/Python/import.c b/Python/import.c
index f43a47c1c472..ccbd949e624f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -701,7 +701,7 @@ remove_module(const char *name)
if (PyDict_GetItemString(modules, name) == NULL)
return;
if (PyDict_DelItemString(modules, name) < 0)
- Py_FatalError("import: deleting existing key in"
+ Py_FatalError("import: deleting existing key in "
"sys.modules failed");
}
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index 57db166df1e1..fbf32d608b8d 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -1808,7 +1808,7 @@ def finalize(self):
print>>fp, ''
print>>fp, ''
print>>fp, ''
- print>>fp, ('>fp, ('')
print>>fp, ''
print>>fp, ''
@@ -1833,7 +1833,7 @@ def finalize(self):
print>>fp, ''
print>>fp, ''
print>>fp, ''
- print>>fp, ('>fp, ('')
print>>fp, ''
print>>fp, ''
From webhook-mailer at python.org Mon Nov 5 11:44:13 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 16:44:13 -0000
Subject: [Python-checkins] [3.7] bpo-35167: Specify program for json.tool
command line options. (GH-10332) (GH-10338)
Message-ID:
https://github.com/python/cpython/commit/6ad277b2592cfac0f138e9adca4374dd1f354bdf
commit: 6ad277b2592cfac0f138e9adca4374dd1f354bdf
branch: 3.7
author: Serhiy Storchaka
committer: GitHub
date: 2018-11-05T18:44:08+02:00
summary:
[3.7] bpo-35167: Specify program for json.tool command line options. (GH-10332) (GH-10338)
(cherry picked from commit 083a7a172b8c8888252d72031f21dcfea3c0d73f)
files:
M Doc/library/json.rst
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 8ce493d63995..510e30733fed 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -648,7 +648,9 @@ when serializing Python :class:`int` values of extremely large magnitude, or
when serializing instances of "exotic" numerical types such as
:class:`decimal.Decimal`.
+
.. _json-commandline:
+.. program:: json.tool
Command Line Interface
----------------------
@@ -680,6 +682,7 @@ specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively:
:option:`--sort-keys` option to sort the output of dictionaries
alphabetically by key.
+
Command line options
^^^^^^^^^^^^^^^^^^^^
From webhook-mailer at python.org Mon Nov 5 12:51:42 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 17:51:42 -0000
Subject: [Python-checkins] [3.6] bpo-35167: Specify program for json.tool
command line options. (GH-10332) (GH-10338) (GH-10339)
Message-ID:
https://github.com/python/cpython/commit/8c5f14d9c137fbffbb9de7c62ca834df2e9fbf2a
commit: 8c5f14d9c137fbffbb9de7c62ca834df2e9fbf2a
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka
date: 2018-11-05T19:51:36+02:00
summary:
[3.6] bpo-35167: Specify program for json.tool command line options. (GH-10332) (GH-10338) (GH-10339)
(cherry picked from commit 083a7a172b8c8888252d72031f21dcfea3c0d73f)
(cherry picked from commit 6ad277b2592cfac0f138e9adca4374dd1f354bdf)
files:
M Doc/library/json.rst
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index aa9da9130308..98ca86e4b9af 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -652,7 +652,9 @@ when serializing Python :class:`int` values of extremely large magnitude, or
when serializing instances of "exotic" numerical types such as
:class:`decimal.Decimal`.
+
.. _json-commandline:
+.. program:: json.tool
Command Line Interface
----------------------
@@ -684,6 +686,7 @@ specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively:
:option:`--sort-keys` option to sort the output of dictionaries
alphabetically by key.
+
Command line options
^^^^^^^^^^^^^^^^^^^^
From webhook-mailer at python.org Mon Nov 5 14:26:43 2018
From: webhook-mailer at python.org (Serhiy Storchaka)
Date: Mon, 05 Nov 2018 19:26:43 -0000
Subject: [Python-checkins] Fix possible crashes in pwdmodule.c. (GH-10331)
Message-ID:
https://github.com/python/cpython/commit/570e371fd6e8615ece9b9e21fbe77149ebeb172e
commit: 570e371fd6e8615ece9b9e21fbe77149ebeb172e
branch: master
author: Zackery Spytz
committer: Serhiy Storchaka
date: 2018-11-05T21:26:40+02:00
summary:
Fix possible crashes in pwdmodule.c. (GH-10331)
"p" was not initialized if the first PyMem_RawRealloc() call failed.
files:
M Modules/pwdmodule.c
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index 1286e7d5ce59..fd11f848b2ce 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -145,6 +145,7 @@ pwd_getpwuid(PyObject *module, PyObject *uidobj)
while(1) {
buf2 = PyMem_RawRealloc(buf, bufsize);
if (buf2 == NULL) {
+ p = NULL;
nomem = 1;
break;
}
@@ -227,6 +228,7 @@ pwd_getpwnam_impl(PyObject *module, PyObject *name)
while(1) {
buf2 = PyMem_RawRealloc(buf, bufsize);
if (buf2 == NULL) {
+ p = NULL;
nomem = 1;
break;
}
From webhook-mailer at python.org Mon Nov 5 17:41:28 2018
From: webhook-mailer at python.org (Victor Stinner)
Date: Mon, 05 Nov 2018 22:41:28 -0000
Subject: [Python-checkins] [Docs] Fix required version of an example of
importlib (GH-10118)
Message-ID:
https://github.com/python/cpython/commit/16c8a53490a22bd4fcde2efaf4694dd06ded882b
commit: 16c8a53490a22bd4fcde2efaf4694dd06ded882b
branch: master
author: E Kawashima
committer: Victor Stinner
date: 2018-11-05T23:41:17+01:00
summary:
[Docs] Fix required version of an example of importlib (GH-10118)
?31.5.6.3. Importing a source file directly: `module_from_spec` is new in Python 3.5.
files:
M Doc/library/importlib.rst
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index c6c7160a9d15..0bcfbb1c7263 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1653,7 +1653,7 @@ Importing a source file directly
''''''''''''''''''''''''''''''''
To import a Python source file directly, use the following recipe
-(Python 3.4 and newer only)::
+(Python 3.5 and newer only)::
import importlib.util
import sys
From webhook-mailer at python.org Mon Nov 5 17:46:46 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Mon, 05 Nov 2018 22:46:46 -0000
Subject: [Python-checkins] [Docs] Fix required version of an example of
importlib (GH-10118)
Message-ID:
https://github.com/python/cpython/commit/91a19c923c83471f305e64ca021bee2e9171965e
commit: 91a19c923c83471f305e64ca021bee2e9171965e
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T14:46:42-08:00
summary:
[Docs] Fix required version of an example of importlib (GH-10118)
?31.5.6.3. Importing a source file directly: `module_from_spec` is new in Python 3.5.
(cherry picked from commit 16c8a53490a22bd4fcde2efaf4694dd06ded882b)
Co-authored-by: E Kawashima
files:
M Doc/library/importlib.rst
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index c6c7160a9d15..0bcfbb1c7263 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1653,7 +1653,7 @@ Importing a source file directly
''''''''''''''''''''''''''''''''
To import a Python source file directly, use the following recipe
-(Python 3.4 and newer only)::
+(Python 3.5 and newer only)::
import importlib.util
import sys
From webhook-mailer at python.org Mon Nov 5 17:47:54 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Mon, 05 Nov 2018 22:47:54 -0000
Subject: [Python-checkins] [Docs] Fix required version of an example of
importlib (GH-10118)
Message-ID:
https://github.com/python/cpython/commit/47a940e83b2482d17c92deebf6b7c9be8cec979d
commit: 47a940e83b2482d17c92deebf6b7c9be8cec979d
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T14:47:51-08:00
summary:
[Docs] Fix required version of an example of importlib (GH-10118)
?31.5.6.3. Importing a source file directly: `module_from_spec` is new in Python 3.5.
(cherry picked from commit 16c8a53490a22bd4fcde2efaf4694dd06ded882b)
Co-authored-by: E Kawashima
files:
M Doc/library/importlib.rst
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 760489ae5560..25055f7ce39c 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1404,7 +1404,7 @@ Importing a source file directly
''''''''''''''''''''''''''''''''
To import a Python source file directly, use the following recipe
-(Python 3.4 and newer only)::
+(Python 3.5 and newer only)::
import importlib.util
import sys
From webhook-mailer at python.org Mon Nov 5 19:38:58 2018
From: webhook-mailer at python.org (INADA Naoki)
Date: Tue, 06 Nov 2018 00:38:58 -0000
Subject: [Python-checkins] bpo-33462: Add __reversed__ to dict and dict
views (GH-6827)
Message-ID:
https://github.com/python/cpython/commit/6531bf6309c8fda1954060a0fb5ea930b1efb656
commit: 6531bf6309c8fda1954060a0fb5ea930b1efb656
branch: master
author: R?mi Lapeyre
committer: INADA Naoki
date: 2018-11-06T09:38:54+09:00
summary:
bpo-33462: Add __reversed__ to dict and dict views (GH-6827)
files:
A Misc/NEWS.d/next/Core and Builtins/2018-05-23-17-18-02.bpo-33462.gurbpbrhe.rst
M Doc/library/stdtypes.rst
M Doc/whatsnew/3.8.rst
M Include/dictobject.h
M Lib/test/test_collections.py
M Lib/test/test_dict.py
M Lib/test/test_enumerate.py
M Objects/clinic/dictobject.c.h
M Objects/dictobject.c
M Objects/object.c
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 4686cec96885..49d433805a32 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -4285,6 +4285,11 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
LIFO order is now guaranteed. In prior versions, :meth:`popitem` would
return an arbitrary key/value pair.
+ .. describe:: reversed(d)
+
+ Return a reversed iterator over the keys of the dictionary. This is a
+ shortcut for ``reversed(d.keys())``.
+
.. method:: setdefault(key[, default])
If *key* is in the dictionary, return its value. If not, insert *key*
@@ -4332,6 +4337,22 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
Dictionary order is guaranteed to be insertion order. This behavior was
implementation detail of CPython from 3.6.
+ Dictionaries and dictionary views are reversible. ::
+
+ >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
+ >>> d
+ {'one': 1, 'two': 2, 'three': 3, 'four': 4}
+ >>> list(reversed(d))
+ ['four', 'three', 'two', 'one']
+ >>> list(reversed(d.values()))
+ [4, 3, 2, 1]
+ >>> list(reversed(d.items()))
+ [('four', 4), ('three', 3), ('two', 2), ('one', 1)]
+
+ .. versionchanged:: 3.8
+ Dictionaries are now reversible.
+
+
.. seealso::
:class:`types.MappingProxyType` can be used to create a read-only view
of a :class:`dict`.
@@ -4375,6 +4396,14 @@ support membership tests:
Return ``True`` if *x* is in the underlying dictionary's keys, values or
items (in the latter case, *x* should be a ``(key, value)`` tuple).
+.. describe:: reversed(dictview)
+
+ Return an reversed iterator over the keys, values or items of the dictionnary.
+ The view will be iterated in reverse order of the insertion.
+
+ .. versionchanged:: 3.8
+ Dictionary views are now reversible.
+
Keys views are set-like since their entries are unique and hashable. If all
values are hashable, so that ``(key, value)`` pairs are unique and hashable,
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 566c369c85bd..2d3a116df9d3 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -98,6 +98,9 @@ Other Language Changes
* Added support of ``\N{name}`` escapes in :mod:`regular expressions `.
(Contributed by Jonathan Eunice and Serhiy Storchaka in :issue:`30688`.)
+* Dict and dictviews are now iterable in reversed insertion order using
+ :func:`reversed`. (Contributed by R?mi Lapeyre in :issue:`33462`.)
+
* The syntax allowed for keyword names in function calls was further
restricted. In particular, ``f((keyword)=arg)`` is no longer allowed. It was
never intended to permit more than a bare name on the left-hand side of a
diff --git a/Include/dictobject.h b/Include/dictobject.h
index 28930f436d70..c0f24df7d265 100644
--- a/Include/dictobject.h
+++ b/Include/dictobject.h
@@ -51,6 +51,9 @@ PyAPI_DATA(PyTypeObject) PyDict_Type;
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
+PyAPI_DATA(PyTypeObject) PyDictRevIterKey_Type;
+PyAPI_DATA(PyTypeObject) PyDictRevIterItem_Type;
+PyAPI_DATA(PyTypeObject) PyDictRevIterValue_Type;
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 0b7cb5848b1b..200e0273c33e 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -796,22 +796,21 @@ class ItBlocked(It):
def test_Reversible(self):
# Check some non-reversibles
- non_samples = [None, 42, 3.14, 1j, dict(), set(), frozenset()]
+ non_samples = [None, 42, 3.14, 1j, set(), frozenset()]
for x in non_samples:
self.assertNotIsInstance(x, Reversible)
self.assertFalse(issubclass(type(x), Reversible), repr(type(x)))
# Check some non-reversible iterables
- non_reversibles = [dict().keys(), dict().items(), dict().values(),
- Counter(), Counter().keys(), Counter().items(),
- Counter().values(), _test_gen(),
- (x for x in []), iter([]), reversed([])]
+ non_reversibles = [_test_gen(), (x for x in []), iter([]), reversed([])]
for x in non_reversibles:
self.assertNotIsInstance(x, Reversible)
self.assertFalse(issubclass(type(x), Reversible), repr(type(x)))
# Check some reversible iterables
samples = [bytes(), str(), tuple(), list(), OrderedDict(),
OrderedDict().keys(), OrderedDict().items(),
- OrderedDict().values()]
+ OrderedDict().values(), Counter(), Counter().keys(),
+ Counter().items(), Counter().values(), dict(),
+ dict().keys(), dict().items(), dict().values()]
for x in samples:
self.assertIsInstance(x, Reversible)
self.assertTrue(issubclass(type(x), Reversible), repr(type(x)))
@@ -1612,7 +1611,7 @@ def test_MutableMapping_subclass(self):
self.assertIsInstance(z, set)
list(z)
mymap['blue'] = 7 # Shouldn't affect 'z'
- self.assertEqual(sorted(z), [('orange', 3), ('red', 5)])
+ self.assertEqual(z, {('orange', 3), ('red', 5)})
def test_Sequence(self):
for sample in [tuple, list, bytes, str]:
@@ -1767,10 +1766,10 @@ def test_basics(self):
self.assertTrue(issubclass(Counter, Mapping))
self.assertEqual(len(c), 3)
self.assertEqual(sum(c.values()), 6)
- self.assertEqual(sorted(c.values()), [1, 2, 3])
- self.assertEqual(sorted(c.keys()), ['a', 'b', 'c'])
- self.assertEqual(sorted(c), ['a', 'b', 'c'])
- self.assertEqual(sorted(c.items()),
+ self.assertEqual(list(c.values()), [3, 2, 1])
+ self.assertEqual(list(c.keys()), ['a', 'b', 'c'])
+ self.assertEqual(list(c), ['a', 'b', 'c'])
+ self.assertEqual(list(c.items()),
[('a', 3), ('b', 2), ('c', 1)])
self.assertEqual(c['b'], 2)
self.assertEqual(c['z'], 0)
@@ -1784,7 +1783,7 @@ def test_basics(self):
for i in range(5):
self.assertEqual(c.most_common(i),
[('a', 3), ('b', 2), ('c', 1)][:i])
- self.assertEqual(''.join(sorted(c.elements())), 'aaabbc')
+ self.assertEqual(''.join(c.elements()), 'aaabbc')
c['a'] += 1 # increment an existing value
c['b'] -= 2 # sub existing value to zero
del c['c'] # remove an entry
@@ -1793,7 +1792,7 @@ def test_basics(self):
c['e'] = -5 # directly assign a missing value
c['f'] += 4 # add to a missing value
self.assertEqual(c, dict(a=4, b=0, d=-2, e=-5, f=4))
- self.assertEqual(''.join(sorted(c.elements())), 'aaaaffff')
+ self.assertEqual(''.join(c.elements()), 'aaaaffff')
self.assertEqual(c.pop('f'), 4)
self.assertNotIn('f', c)
for i in range(3):
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 90c0a3131a78..71fffe398f34 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1021,7 +1021,7 @@ def test_iterator_pickling(self):
it = iter(data)
d = pickle.dumps(it, proto)
it = pickle.loads(d)
- self.assertEqual(sorted(it), sorted(data))
+ self.assertEqual(list(it), list(data))
it = pickle.loads(d)
try:
@@ -1031,7 +1031,7 @@ def test_iterator_pickling(self):
d = pickle.dumps(it, proto)
it = pickle.loads(d)
del data[drop]
- self.assertEqual(sorted(it), sorted(data))
+ self.assertEqual(list(it), list(data))
def test_itemiterator_pickling(self):
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -1062,7 +1062,7 @@ def test_valuesiterator_pickling(self):
it = iter(data.values())
d = pickle.dumps(it, proto)
it = pickle.loads(d)
- self.assertEqual(sorted(list(it)), sorted(list(data.values())))
+ self.assertEqual(list(it), list(data.values()))
it = pickle.loads(d)
drop = next(it)
@@ -1071,6 +1071,62 @@ def test_valuesiterator_pickling(self):
values = list(it) + [drop]
self.assertEqual(sorted(values), sorted(list(data.values())))
+ def test_reverseiterator_pickling(self):
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ data = {1:"a", 2:"b", 3:"c"}
+ it = reversed(data)
+ d = pickle.dumps(it, proto)
+ it = pickle.loads(d)
+ self.assertEqual(list(it), list(reversed(data)))
+
+ it = pickle.loads(d)
+ try:
+ drop = next(it)
+ except StopIteration:
+ continue
+ d = pickle.dumps(it, proto)
+ it = pickle.loads(d)
+ del data[drop]
+ self.assertEqual(list(it), list(reversed(data)))
+
+ def test_reverseitemiterator_pickling(self):
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ data = {1:"a", 2:"b", 3:"c"}
+ # dictviews aren't picklable, only their iterators
+ itorg = reversed(data.items())
+ d = pickle.dumps(itorg, proto)
+ it = pickle.loads(d)
+ # note that the type of the unpickled iterator
+ # is not necessarily the same as the original. It is
+ # merely an object supporting the iterator protocol, yielding
+ # the same objects as the original one.
+ # self.assertEqual(type(itorg), type(it))
+ self.assertIsInstance(it, collections.abc.Iterator)
+ self.assertEqual(dict(it), data)
+
+ it = pickle.loads(d)
+ drop = next(it)
+ d = pickle.dumps(it, proto)
+ it = pickle.loads(d)
+ del data[drop[0]]
+ self.assertEqual(dict(it), data)
+
+ def test_reversevaluesiterator_pickling(self):
+ for proto in range(pickle.HIGHEST_PROTOCOL):
+ data = {1:"a", 2:"b", 3:"c"}
+ # data.values() isn't picklable, only its iterator
+ it = reversed(data.values())
+ d = pickle.dumps(it, proto)
+ it = pickle.loads(d)
+ self.assertEqual(list(it), list(reversed(data.values())))
+
+ it = pickle.loads(d)
+ drop = next(it)
+ d = pickle.dumps(it, proto)
+ it = pickle.loads(d)
+ values = list(it) + [drop]
+ self.assertEqual(sorted(values), sorted(data.values()))
+
def test_instance_dict_getattr_str_subclass(self):
class Foo:
def __init__(self, msg):
@@ -1222,6 +1278,13 @@ def iter_and_mutate():
self.assertRaises(RuntimeError, iter_and_mutate)
+ def test_reversed(self):
+ d = {"a": 1, "b": 2, "foo": 0, "c": 3, "d": 4}
+ del d["foo"]
+ r = reversed(d)
+ self.assertEqual(list(r), list('dcba'))
+ self.assertRaises(StopIteration, next, r)
+
def test_dict_copy_order(self):
# bpo-34320
od = collections.OrderedDict([('a', 1), ('b', 2)])
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py
index e455adee50fe..5785cb46492e 100644
--- a/Lib/test/test_enumerate.py
+++ b/Lib/test/test_enumerate.py
@@ -160,9 +160,9 @@ def __getitem__(self, i):
raise StopIteration
def __len__(self):
return 5
- for data in 'abc', range(5), tuple(enumerate('abc')), A(), range(1,17,5):
+ for data in ('abc', range(5), tuple(enumerate('abc')), A(),
+ range(1,17,5), dict.fromkeys('abcde')):
self.assertEqual(list(data)[::-1], list(reversed(data)))
- self.assertRaises(TypeError, reversed, {})
# don't allow keyword arguments
self.assertRaises(TypeError, reversed, [], a=1)
diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-05-23-17-18-02.bpo-33462.gurbpbrhe.rst b/Misc/NEWS.d/next/Core and Builtins/2018-05-23-17-18-02.bpo-33462.gurbpbrhe.rst
new file mode 100644
index 000000000000..ed1f0342731e
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2018-05-23-17-18-02.bpo-33462.gurbpbrhe.rst
@@ -0,0 +1 @@
+Make dict and dict views reversible. Patch by R?mi Lapeyre.
diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index 58677cd772bc..4f4c9fa9cb7a 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -103,4 +103,22 @@ dict_setdefault(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=d7508c5091609a23 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(dict___reversed____doc__,
+"__reversed__($self, /)\n"
+"--\n"
+"\n"
+"Return a reverse iterator over the dict keys.");
+
+#define DICT___REVERSED___METHODDEF \
+ {"__reversed__", (PyCFunction)dict___reversed__, METH_NOARGS, dict___reversed____doc__},
+
+static PyObject *
+dict___reversed___impl(PyDictObject *self);
+
+static PyObject *
+dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
+{
+ return dict___reversed___impl(self);
+}
+/*[clinic end generated code: output=b9923851cbd9213a input=a9049054013a1b77]*/
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index ea564a2b7c9f..08ec9e254ab2 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -3100,6 +3100,7 @@ static PyMethodDef mapp_methods[] = {
clear__doc__},
{"copy", (PyCFunction)dict_copy, METH_NOARGS,
copy__doc__},
+ DICT___REVERSED___METHODDEF
{NULL, NULL} /* sentinel */
};
@@ -3335,22 +3336,32 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
{
dictiterobject *di;
di = PyObject_GC_New(dictiterobject, itertype);
- if (di == NULL)
+ if (di == NULL) {
return NULL;
+ }
Py_INCREF(dict);
di->di_dict = dict;
di->di_used = dict->ma_used;
- di->di_pos = 0;
di->len = dict->ma_used;
- if (itertype == &PyDictIterItem_Type) {
+ if ((itertype == &PyDictRevIterKey_Type ||
+ itertype == &PyDictRevIterItem_Type ||
+ itertype == &PyDictRevIterValue_Type) && dict->ma_used) {
+ di->di_pos = dict->ma_keys->dk_nentries - 1;
+ }
+ else {
+ di->di_pos = 0;
+ }
+ if (itertype == &PyDictIterItem_Type ||
+ itertype == &PyDictRevIterItem_Type) {
di->di_result = PyTuple_Pack(2, Py_None, Py_None);
if (di->di_result == NULL) {
Py_DECREF(di);
return NULL;
}
}
- else
+ else {
di->di_result = NULL;
+ }
_PyObject_GC_TRACK(di);
return (PyObject *)di;
}
@@ -3664,6 +3675,120 @@ PyTypeObject PyDictIterItem_Type = {
};
+/* dictreviter */
+
+static PyObject *
+dictreviter_iternext(dictiterobject *di)
+{
+ PyDictObject *d = di->di_dict;
+
+ if (d == NULL) {
+ return NULL;
+ }
+ assert (PyDict_Check(d));
+
+ if (di->di_used != d->ma_used) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "dictionary changed size during iteration");
+ di->di_used = -1; /* Make this state sticky */
+ return NULL;
+ }
+
+ Py_ssize_t i = di->di_pos;
+ PyDictKeysObject *k = d->ma_keys;
+ PyObject *key, *value, *result;
+
+ if (d->ma_values) {
+ if (i < 0) {
+ goto fail;
+ }
+ key = DK_ENTRIES(k)[i].me_key;
+ value = d->ma_values[i];
+ assert (value != NULL);
+ }
+ else {
+ PyDictKeyEntry *entry_ptr = &DK_ENTRIES(k)[i];
+ while (i >= 0 && entry_ptr->me_value == NULL) {
+ entry_ptr--;
+ i--;
+ }
+ if (i < 0) {
+ goto fail;
+ }
+ key = entry_ptr->me_key;
+ value = entry_ptr->me_value;
+ }
+ di->di_pos = i-1;
+ di->len--;
+
+ if (Py_TYPE(di) == &PyDictRevIterKey_Type) {
+ Py_INCREF(key);
+ return key;
+ }
+ else if (Py_TYPE(di) == &PyDictRevIterValue_Type) {
+ Py_INCREF(value);
+ return value;
+ }
+ else if (Py_TYPE(di) == &PyDictRevIterItem_Type) {
+ Py_INCREF(key);
+ Py_INCREF(value);
+ result = di->di_result;
+ if (Py_REFCNT(result) == 1) {
+ PyObject *oldkey = PyTuple_GET_ITEM(result, 0);
+ PyObject *oldvalue = PyTuple_GET_ITEM(result, 1);
+ PyTuple_SET_ITEM(result, 0, key); /* steals reference */
+ PyTuple_SET_ITEM(result, 1, value); /* steals reference */
+ Py_INCREF(result);
+ Py_DECREF(oldkey);
+ Py_DECREF(oldvalue);
+ }
+ else {
+ result = PyTuple_New(2);
+ if (result == NULL) {
+ return NULL;
+ }
+ PyTuple_SET_ITEM(result, 0, key); /* steals reference */
+ PyTuple_SET_ITEM(result, 1, value); /* steals reference */
+ }
+ return result;
+ }
+ else {
+ Py_UNREACHABLE();
+ }
+
+fail:
+ di->di_dict = NULL;
+ Py_DECREF(d);
+ return NULL;
+}
+
+PyTypeObject PyDictRevIterKey_Type = {
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "dict_reversekeyiterator",
+ sizeof(dictiterobject),
+ .tp_dealloc = (destructor)dictiter_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .tp_traverse = (traverseproc)dictiter_traverse,
+ .tp_iter = PyObject_SelfIter,
+ .tp_iternext = (iternextfunc)dictreviter_iternext,
+ .tp_methods = dictiter_methods
+};
+
+
+/*[clinic input]
+dict.__reversed__
+
+Return a reverse iterator over the dict keys.
+[clinic start generated code]*/
+
+static PyObject *
+dict___reversed___impl(PyDictObject *self)
+/*[clinic end generated code: output=e674483336d1ed51 input=23210ef3477d8c4d]*/
+{
+ assert (PyDict_Check(self));
+ return dictiter_new(self, &PyDictRevIterKey_Type);
+}
+
static PyObject *
dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored))
{
@@ -3671,7 +3796,6 @@ dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored))
dictiterobject tmp = *di;
Py_XINCREF(tmp.di_dict);
- /* iterate the temporary into a list */
PyObject *list = PySequence_List((PyObject*)&tmp);
Py_XDECREF(tmp.di_dict);
if (list == NULL) {
@@ -3680,6 +3804,30 @@ dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored))
return Py_BuildValue("N(N)", _PyObject_GetBuiltin("iter"), list);
}
+PyTypeObject PyDictRevIterItem_Type = {
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "dict_reverseitemiterator",
+ sizeof(dictiterobject),
+ .tp_dealloc = (destructor)dictiter_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .tp_traverse = (traverseproc)dictiter_traverse,
+ .tp_iter = PyObject_SelfIter,
+ .tp_iternext = (iternextfunc)dictreviter_iternext,
+ .tp_methods = dictiter_methods
+};
+
+PyTypeObject PyDictRevIterValue_Type = {
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "dict_reversevalueiterator",
+ sizeof(dictiterobject),
+ .tp_dealloc = (destructor)dictiter_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+ .tp_traverse = (traverseproc)dictiter_traverse,
+ .tp_iter = PyObject_SelfIter,
+ .tp_iternext = (iternextfunc)dictreviter_iternext,
+ .tp_methods = dictiter_methods
+};
+
/***********************************************/
/* View objects for keys(), items(), values(). */
/***********************************************/
@@ -4035,9 +4183,16 @@ dictviews_isdisjoint(PyObject *self, PyObject *other)
PyDoc_STRVAR(isdisjoint_doc,
"Return True if the view and the given iterable have a null intersection.");
+static PyObject* dictkeys_reversed(_PyDictViewObject *dv);
+
+PyDoc_STRVAR(reversed_keys_doc,
+"Return a reverse iterator over the dict keys.");
+
static PyMethodDef dictkeys_methods[] = {
{"isdisjoint", (PyCFunction)dictviews_isdisjoint, METH_O,
isdisjoint_doc},
+ {"__reversed__", (PyCFunction)dictkeys_reversed, METH_NOARGS,
+ reversed_keys_doc},
{NULL, NULL} /* sentinel */
};
@@ -4080,6 +4235,15 @@ dictkeys_new(PyObject *dict, PyObject *Py_UNUSED(ignored))
return _PyDictView_New(dict, &PyDictKeys_Type);
}
+static PyObject *
+dictkeys_reversed(_PyDictViewObject *dv)
+{
+ if (dv->dv_dict == NULL) {
+ Py_RETURN_NONE;
+ }
+ return dictiter_new(dv->dv_dict, &PyDictRevIterKey_Type);
+}
+
/*** dict_items ***/
static PyObject *
@@ -4125,9 +4289,16 @@ static PySequenceMethods dictitems_as_sequence = {
(objobjproc)dictitems_contains, /* sq_contains */
};
+static PyObject* dictitems_reversed(_PyDictViewObject *dv);
+
+PyDoc_STRVAR(reversed_items_doc,
+"Return a reverse iterator over the dict items.");
+
static PyMethodDef dictitems_methods[] = {
{"isdisjoint", (PyCFunction)dictviews_isdisjoint, METH_O,
isdisjoint_doc},
+ {"__reversed__", (PyCFunction)dictitems_reversed, METH_NOARGS,
+ reversed_items_doc},
{NULL, NULL} /* sentinel */
};
@@ -4170,6 +4341,15 @@ dictitems_new(PyObject *dict, PyObject *Py_UNUSED(ignored))
return _PyDictView_New(dict, &PyDictItems_Type);
}
+static PyObject *
+dictitems_reversed(_PyDictViewObject *dv)
+{
+ if (dv->dv_dict == NULL) {
+ Py_RETURN_NONE;
+ }
+ return dictiter_new(dv->dv_dict, &PyDictRevIterItem_Type);
+}
+
/*** dict_values ***/
static PyObject *
@@ -4192,7 +4372,14 @@ static PySequenceMethods dictvalues_as_sequence = {
(objobjproc)0, /* sq_contains */
};
+static PyObject* dictvalues_reversed(_PyDictViewObject *dv);
+
+PyDoc_STRVAR(reversed_values_doc,
+"Return a reverse iterator over the dict values.");
+
static PyMethodDef dictvalues_methods[] = {
+ {"__reversed__", (PyCFunction)dictvalues_reversed, METH_NOARGS,
+ reversed_values_doc},
{NULL, NULL} /* sentinel */
};
@@ -4235,6 +4422,16 @@ dictvalues_new(PyObject *dict, PyObject *Py_UNUSED(ignored))
return _PyDictView_New(dict, &PyDictValues_Type);
}
+static PyObject *
+dictvalues_reversed(_PyDictViewObject *dv)
+{
+ if (dv->dv_dict == NULL) {
+ Py_RETURN_NONE;
+ }
+ return dictiter_new(dv->dv_dict, &PyDictRevIterValue_Type);
+}
+
+
/* Returns NULL if cannot allocate a new PyDictKeysObject,
but does not set an error */
PyDictKeysObject *
diff --git a/Objects/object.c b/Objects/object.c
index d3a97f6c5bd4..72e2684820ce 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1790,6 +1790,15 @@ _Py_ReadyTypes(void)
if (PyType_Ready(&PyDictItems_Type) < 0)
Py_FatalError("Can't initialize dict items type");
+ if (PyType_Ready(&PyDictRevIterKey_Type) < 0)
+ Py_FatalError("Can't initialize reversed dict keys type");
+
+ if (PyType_Ready(&PyDictRevIterValue_Type) < 0)
+ Py_FatalError("Can't initialize reversed dict values type");
+
+ if (PyType_Ready(&PyDictRevIterItem_Type) < 0)
+ Py_FatalError("Can't initialize reversed dict items type");
+
if (PyType_Ready(&PyODict_Type) < 0)
Py_FatalError("Can't initialize OrderedDict type");
From webhook-mailer at python.org Mon Nov 5 20:53:26 2018
From: webhook-mailer at python.org (Ivan Levkivskyi)
Date: Tue, 06 Nov 2018 01:53:26 -0000
Subject: [Python-checkins] bpo-35119: Fix RecursionError in example of
customizing module attribute access. (GH-10323)
Message-ID:
https://github.com/python/cpython/commit/0bee3c36d406e47fa9f99cfc1e07b701512c4f3f
commit: 0bee3c36d406e47fa9f99cfc1e07b701512c4f3f
branch: master
author: Denis Osipov
committer: Ivan Levkivskyi
date: 2018-11-06T01:53:21Z
summary:
bpo-35119: Fix RecursionError in example of customizing module attribute access. (GH-10323)
https://bugs.python.org/issue35119
files:
M Doc/reference/datamodel.rst
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 6067c7252682..24c647d1a8d2 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1580,7 +1580,7 @@ a module object to a subclass of :class:`types.ModuleType`. For example::
def __setattr__(self, attr, value):
print(f'Setting {attr}...')
- setattr(self, attr, value)
+ super().__setattr__(attr, value)
sys.modules[__name__].__class__ = VerboseModule
From webhook-mailer at python.org Mon Nov 5 20:59:19 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 01:59:19 -0000
Subject: [Python-checkins] bpo-35119: Fix RecursionError in example of
customizing module attribute access. (GH-10323)
Message-ID:
https://github.com/python/cpython/commit/558dc8adbec0b85e0ff257fcedc85c5d89cd2825
commit: 558dc8adbec0b85e0ff257fcedc85c5d89cd2825
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T17:59:15-08:00
summary:
bpo-35119: Fix RecursionError in example of customizing module attribute access. (GH-10323)
https://bugs.python.org/issue35119
(cherry picked from commit 0bee3c36d406e47fa9f99cfc1e07b701512c4f3f)
Co-authored-by: Denis Osipov
files:
M Doc/reference/datamodel.rst
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 2012d7abc23f..be9b3ad1af69 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1580,7 +1580,7 @@ a module object to a subclass of :class:`types.ModuleType`. For example::
def __setattr__(self, attr, value):
print(f'Setting {attr}...')
- setattr(self, attr, value)
+ super().__setattr__(attr, value)
sys.modules[__name__].__class__ = VerboseModule
From webhook-mailer at python.org Mon Nov 5 21:30:37 2018
From: webhook-mailer at python.org (Terry Jan Reedy)
Date: Tue, 06 Nov 2018 02:30:37 -0000
Subject: [Python-checkins] bpo-35099: Improve the doc about IDLE running
user code. (#10350)
Message-ID:
https://github.com/python/cpython/commit/5e7909032491cef17754a3208872655fe350e9be
commit: 5e7909032491cef17754a3208872655fe350e9be
branch: master
author: Terry Jan Reedy
committer: GitHub
date: 2018-11-05T21:30:32-05:00
summary:
bpo-35099: Improve the doc about IDLE running user code. (#10350)
The section is renamed from "IDLE -- console differences". It mostly
covers the implications of using custom sys.stdxxx objects.
files:
A Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
M Doc/library/idle.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index 645bd612618b..c5015bf30cfb 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -563,7 +563,6 @@ looked for in the user's home directory. Statements in this file will be
executed in the Tk namespace, so this file is not useful for importing
functions to be used from IDLE's Python shell.
-
Command line usage
^^^^^^^^^^^^^^^^^^
@@ -591,7 +590,6 @@ If there are arguments:
* Otherwise, arguments are files opened for editing and
``sys.argv`` reflects the arguments passed to IDLE itself.
-
Startup failure
^^^^^^^^^^^^^^^
@@ -635,27 +633,38 @@ be to delete one or more of the configuration files.
If IDLE quits with no message, and it was not started from a console, try
starting from a console (``python -m idlelib)`` and see if a message appears.
-
-IDLE-console differences
-^^^^^^^^^^^^^^^^^^^^^^^^
+Running user code
+^^^^^^^^^^^^^^^^^
With rare exceptions, the result of executing Python code with IDLE is
-intended to be the same as executing the same code in a console window.
+intended to be the same as executing the same code by the default method,
+directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
-visible results. For instance, ``sys.modules`` starts with more entries.
+visible results. For instance, ``sys.modules`` starts with more entries,
+and ``threading.activeCount()`` returns 2 instead of 1.
+
+By default, IDLE runs user code in a separate OS process rather than in
+the user interface process that runs the shell and editor. In the execution
+process, it replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr``
+with objects that get input from and send output to the Shell window.
+The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and
+``sys.__stderr__`` are not touched, but may be ``None``.
-IDLE also replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` with
-objects that get input from and send output to the Shell window.
When Shell has the focus, it controls the keyboard and screen. This is
normally transparent, but functions that directly access the keyboard
-and screen will not work. If ``sys`` is reset with ``importlib.reload(sys)``,
-IDLE's changes are lost and things like ``input``, ``raw_input``, and
-``print`` will not work correctly.
-
-With IDLE's Shell, one enters, edits, and recalls complete statements.
-Some consoles only work with a single physical line at a time. IDLE uses
-``exec`` to run each statement. As a result, ``'__builtins__'`` is always
-defined for each statement.
+and screen will not work. These include system-specific functions that
+determine whether a key has been pressed and if so, which.
+
+IDLE's standard stream replacements are not inherited by subprocesses
+created in the execution process, whether directly by user code or by modules
+such as multiprocessing. If such subprocess use ``input`` from sys.stdin
+or ``print`` or ``write`` to sys.stdout or sys.stderr,
+IDLE should be started in a command line window. The secondary subprocess
+will then be attached to that window for input and output.
+
+If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
+IDLE's changes are lost and input from the keyboard and output to the screen
+will not work correctly.
Developing tkinter applications
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
new file mode 100644
index 000000000000..1459f20cb78f
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
@@ -0,0 +1,3 @@
+Improve the doc about IDLE running user code. The section is renamed from
+"IDLE -- console differences" is renamed "Running user code".
+It mostly covers the implications of using custom sys.stdxxx objects.
From webhook-mailer at python.org Mon Nov 5 21:35:23 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 02:35:23 -0000
Subject: [Python-checkins] bpo-35099: Improve the doc about IDLE running
user code. (GH-10350)
Message-ID:
https://github.com/python/cpython/commit/a437c285fa4f21720802e7a91770b2281d576554
commit: a437c285fa4f21720802e7a91770b2281d576554
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T18:35:18-08:00
summary:
bpo-35099: Improve the doc about IDLE running user code. (GH-10350)
The section is renamed from "IDLE -- console differences". It mostly
covers the implications of using custom sys.stdxxx objects.
(cherry picked from commit 5e7909032491cef17754a3208872655fe350e9be)
Co-authored-by: Terry Jan Reedy
files:
A Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
M Doc/library/idle.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index 645bd612618b..c5015bf30cfb 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -563,7 +563,6 @@ looked for in the user's home directory. Statements in this file will be
executed in the Tk namespace, so this file is not useful for importing
functions to be used from IDLE's Python shell.
-
Command line usage
^^^^^^^^^^^^^^^^^^
@@ -591,7 +590,6 @@ If there are arguments:
* Otherwise, arguments are files opened for editing and
``sys.argv`` reflects the arguments passed to IDLE itself.
-
Startup failure
^^^^^^^^^^^^^^^
@@ -635,27 +633,38 @@ be to delete one or more of the configuration files.
If IDLE quits with no message, and it was not started from a console, try
starting from a console (``python -m idlelib)`` and see if a message appears.
-
-IDLE-console differences
-^^^^^^^^^^^^^^^^^^^^^^^^
+Running user code
+^^^^^^^^^^^^^^^^^
With rare exceptions, the result of executing Python code with IDLE is
-intended to be the same as executing the same code in a console window.
+intended to be the same as executing the same code by the default method,
+directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
-visible results. For instance, ``sys.modules`` starts with more entries.
+visible results. For instance, ``sys.modules`` starts with more entries,
+and ``threading.activeCount()`` returns 2 instead of 1.
+
+By default, IDLE runs user code in a separate OS process rather than in
+the user interface process that runs the shell and editor. In the execution
+process, it replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr``
+with objects that get input from and send output to the Shell window.
+The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and
+``sys.__stderr__`` are not touched, but may be ``None``.
-IDLE also replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` with
-objects that get input from and send output to the Shell window.
When Shell has the focus, it controls the keyboard and screen. This is
normally transparent, but functions that directly access the keyboard
-and screen will not work. If ``sys`` is reset with ``importlib.reload(sys)``,
-IDLE's changes are lost and things like ``input``, ``raw_input``, and
-``print`` will not work correctly.
-
-With IDLE's Shell, one enters, edits, and recalls complete statements.
-Some consoles only work with a single physical line at a time. IDLE uses
-``exec`` to run each statement. As a result, ``'__builtins__'`` is always
-defined for each statement.
+and screen will not work. These include system-specific functions that
+determine whether a key has been pressed and if so, which.
+
+IDLE's standard stream replacements are not inherited by subprocesses
+created in the execution process, whether directly by user code or by modules
+such as multiprocessing. If such subprocess use ``input`` from sys.stdin
+or ``print`` or ``write`` to sys.stdout or sys.stderr,
+IDLE should be started in a command line window. The secondary subprocess
+will then be attached to that window for input and output.
+
+If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
+IDLE's changes are lost and input from the keyboard and output to the screen
+will not work correctly.
Developing tkinter applications
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
new file mode 100644
index 000000000000..1459f20cb78f
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
@@ -0,0 +1,3 @@
+Improve the doc about IDLE running user code. The section is renamed from
+"IDLE -- console differences" is renamed "Running user code".
+It mostly covers the implications of using custom sys.stdxxx objects.
From webhook-mailer at python.org Mon Nov 5 21:35:54 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 02:35:54 -0000
Subject: [Python-checkins] bpo-35099: Improve the doc about IDLE running
user code. (GH-10350)
Message-ID:
https://github.com/python/cpython/commit/927a113ae2be33a9dd929569930f28948aa5c965
commit: 927a113ae2be33a9dd929569930f28948aa5c965
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T18:35:51-08:00
summary:
bpo-35099: Improve the doc about IDLE running user code. (GH-10350)
The section is renamed from "IDLE -- console differences". It mostly
covers the implications of using custom sys.stdxxx objects.
(cherry picked from commit 5e7909032491cef17754a3208872655fe350e9be)
Co-authored-by: Terry Jan Reedy
files:
A Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
M Doc/library/idle.rst
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index 0826d99b6336..a4432190bbb0 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -563,7 +563,6 @@ looked for in the user's home directory. Statements in this file will be
executed in the Tk namespace, so this file is not useful for importing
functions to be used from IDLE's Python shell.
-
Command line usage
^^^^^^^^^^^^^^^^^^
@@ -591,7 +590,6 @@ If there are arguments:
* Otherwise, arguments are files opened for editing and
``sys.argv`` reflects the arguments passed to IDLE itself.
-
Startup failure
^^^^^^^^^^^^^^^
@@ -635,27 +633,38 @@ be to delete one or more of the configuration files.
If IDLE quits with no message, and it was not started from a console, try
starting from a console (``python -m idlelib)`` and see if a message appears.
-
-IDLE-console differences
-^^^^^^^^^^^^^^^^^^^^^^^^
+Running user code
+^^^^^^^^^^^^^^^^^
With rare exceptions, the result of executing Python code with IDLE is
-intended to be the same as executing the same code in a console window.
+intended to be the same as executing the same code by the default method,
+directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
-visible results. For instance, ``sys.modules`` starts with more entries.
+visible results. For instance, ``sys.modules`` starts with more entries,
+and ``threading.activeCount()`` returns 2 instead of 1.
+
+By default, IDLE runs user code in a separate OS process rather than in
+the user interface process that runs the shell and editor. In the execution
+process, it replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr``
+with objects that get input from and send output to the Shell window.
+The original values stored in ``sys.__stdin__``, ``sys.__stdout__``, and
+``sys.__stderr__`` are not touched, but may be ``None``.
-IDLE also replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` with
-objects that get input from and send output to the Shell window.
When Shell has the focus, it controls the keyboard and screen. This is
normally transparent, but functions that directly access the keyboard
-and screen will not work. If ``sys`` is reset with ``importlib.reload(sys)``,
-IDLE's changes are lost and things like ``input``, ``raw_input``, and
-``print`` will not work correctly.
-
-With IDLE's Shell, one enters, edits, and recalls complete statements.
-Some consoles only work with a single physical line at a time. IDLE uses
-``exec`` to run each statement. As a result, ``'__builtins__'`` is always
-defined for each statement.
+and screen will not work. These include system-specific functions that
+determine whether a key has been pressed and if so, which.
+
+IDLE's standard stream replacements are not inherited by subprocesses
+created in the execution process, whether directly by user code or by modules
+such as multiprocessing. If such subprocess use ``input`` from sys.stdin
+or ``print`` or ``write`` to sys.stdout or sys.stderr,
+IDLE should be started in a command line window. The secondary subprocess
+will then be attached to that window for input and output.
+
+If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
+IDLE's changes are lost and input from the keyboard and output to the screen
+will not work correctly.
Developing tkinter applications
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
new file mode 100644
index 000000000000..1459f20cb78f
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-11-05-20-43-08.bpo-35099.SVOZXC.rst
@@ -0,0 +1,3 @@
+Improve the doc about IDLE running user code. The section is renamed from
+"IDLE -- console differences" is renamed "Running user code".
+It mostly covers the implications of using custom sys.stdxxx objects.
From webhook-mailer at python.org Mon Nov 5 22:18:01 2018
From: webhook-mailer at python.org (Terry Jan Reedy)
Date: Tue, 06 Nov 2018 03:18:01 -0000
Subject: [Python-checkins] bpo-35099: Update idlelib/help.html (#10353)
Message-ID:
https://github.com/python/cpython/commit/f1d3efc2fba704692d539acc3cb0376a1dd9d98f
commit: f1d3efc2fba704692d539acc3cb0376a1dd9d98f
branch: master
author: Terry Jan Reedy
committer: GitHub
date: 2018-11-05T22:17:57-05:00
summary:
bpo-35099: Update idlelib/help.html (#10353)
(This should have been done with the first PR for this issue.)
files:
M Lib/idlelib/help.html
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 24fd77da904e..1cd9b6913de8 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -616,23 +616,33 @@ Startup failure
-
-
IDLE-console differences
+
+
Running user code
With rare exceptions, the result of executing Python code with IDLE is
-intended to be the same as executing the same code in a console window.
+intended to be the same as executing the same code by the default method,
+directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
-visible results. For instance, sys.modules
starts with more entries.
-
IDLE also replaces sys.stdin
, sys.stdout
, and sys.stderr
with
-objects that get input from and send output to the Shell window.
-When Shell has the focus, it controls the keyboard and screen. This is
+visible results. For instance, sys.modules
starts with more entries,
+and threading.activeCount()
returns 2 instead of 1.
+
By default, IDLE runs user code in a separate OS process rather than in
+the user interface process that runs the shell and editor. In the execution
+process, it replaces sys.stdin
, sys.stdout
, and sys.stderr
+with objects that get input from and send output to the Shell window.
+The original values stored in sys.__stdin__
, sys.__stdout__
, and
+sys.__stderr__
are not touched, but may be None
.
+
When Shell has the focus, it controls the keyboard and screen. This is
normally transparent, but functions that directly access the keyboard
-and screen will not work. If sys
is reset with importlib.reload(sys)
,
-IDLE?s changes are lost and things like input
, raw_input
, and
-print
will not work correctly.
-
With IDLE?s Shell, one enters, edits, and recalls complete statements.
-Some consoles only work with a single physical line at a time. IDLE uses
-exec
to run each statement. As a result, '__builtins__'
is always
-defined for each statement.
+and screen will not work. These include system-specific functions that
+determine whether a key has been pressed and if so, which.
+
IDLE?s standard stream replacements are not inherited by subprocesses
+created in the execution process, whether directly by user code or by modules
+such as multiprocessing. If such subprocess use input
from sys.stdin
+or print
or write
to sys.stdout or sys.stderr,
+IDLE should be started in a command line window. The secondary subprocess
+will then be attached to that window for input and output.
+
If sys
is reset by user code, such as with importlib.reload(sys)
,
+IDLE?s changes are lost and input from the keyboard and output to the screen
+will not work correctly.
Developing tkinter applications
@@ -752,7 +762,7 @@
Startup and code execution
@@ -841,7 +851,7 @@ Navigation
- Last updated on Oct 28, 2018.
+ Last updated on Nov 05, 2018.
Found a bug?
From webhook-mailer at python.org Mon Nov 5 22:36:18 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 03:36:18 -0000
Subject: [Python-checkins] bpo-35099: Update idlelib/help.html (GH-10353)
Message-ID:
https://github.com/python/cpython/commit/4a46295a95bc2e7a93bcf0ce4cdaeeeb48729069
commit: 4a46295a95bc2e7a93bcf0ce4cdaeeeb48729069
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T19:36:12-08:00
summary:
bpo-35099: Update idlelib/help.html (GH-10353)
(This should have been done with the first PR for this issue.)
(cherry picked from commit f1d3efc2fba704692d539acc3cb0376a1dd9d98f)
Co-authored-by: Terry Jan Reedy
files:
M Lib/idlelib/help.html
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 24fd77da904e..1cd9b6913de8 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -616,23 +616,33 @@ Startup failure
-
-
IDLE-console differences
+
+
Running user code
With rare exceptions, the result of executing Python code with IDLE is
-intended to be the same as executing the same code in a console window.
+intended to be the same as executing the same code by the default method,
+directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
-visible results. For instance, sys.modules
starts with more entries.
-
IDLE also replaces sys.stdin
, sys.stdout
, and sys.stderr
with
-objects that get input from and send output to the Shell window.
-When Shell has the focus, it controls the keyboard and screen. This is
+visible results. For instance, sys.modules
starts with more entries,
+and threading.activeCount()
returns 2 instead of 1.
+
By default, IDLE runs user code in a separate OS process rather than in
+the user interface process that runs the shell and editor. In the execution
+process, it replaces sys.stdin
, sys.stdout
, and sys.stderr
+with objects that get input from and send output to the Shell window.
+The original values stored in sys.__stdin__
, sys.__stdout__
, and
+sys.__stderr__
are not touched, but may be None
.
+
When Shell has the focus, it controls the keyboard and screen. This is
normally transparent, but functions that directly access the keyboard
-and screen will not work. If sys
is reset with importlib.reload(sys)
,
-IDLE?s changes are lost and things like input
, raw_input
, and
-print
will not work correctly.
-
With IDLE?s Shell, one enters, edits, and recalls complete statements.
-Some consoles only work with a single physical line at a time. IDLE uses
-exec
to run each statement. As a result, '__builtins__'
is always
-defined for each statement.
+and screen will not work. These include system-specific functions that
+determine whether a key has been pressed and if so, which.
+
IDLE?s standard stream replacements are not inherited by subprocesses
+created in the execution process, whether directly by user code or by modules
+such as multiprocessing. If such subprocess use input
from sys.stdin
+or print
or write
to sys.stdout or sys.stderr,
+IDLE should be started in a command line window. The secondary subprocess
+will then be attached to that window for input and output.
+
If sys
is reset by user code, such as with importlib.reload(sys)
,
+IDLE?s changes are lost and input from the keyboard and output to the screen
+will not work correctly.
Developing tkinter applications
@@ -752,7 +762,7 @@
Startup and code execution
@@ -841,7 +851,7 @@ Navigation
- Last updated on Oct 28, 2018.
+ Last updated on Nov 05, 2018.
Found a bug?
From webhook-mailer at python.org Mon Nov 5 22:39:58 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 03:39:58 -0000
Subject: [Python-checkins] bpo-35099: Update idlelib/help.html (GH-10353)
Message-ID:
https://github.com/python/cpython/commit/54bcb6c0f185be29b2a626d2f1430c110c823a7d
commit: 54bcb6c0f185be29b2a626d2f1430c110c823a7d
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T19:39:53-08:00
summary:
bpo-35099: Update idlelib/help.html (GH-10353)
(This should have been done with the first PR for this issue.)
(cherry picked from commit f1d3efc2fba704692d539acc3cb0376a1dd9d98f)
Co-authored-by: Terry Jan Reedy
files:
M Lib/idlelib/help.html
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 24fd77da904e..1cd9b6913de8 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -616,23 +616,33 @@ Startup failure
-
-
IDLE-console differences
+
+
Running user code
With rare exceptions, the result of executing Python code with IDLE is
-intended to be the same as executing the same code in a console window.
+intended to be the same as executing the same code by the default method,
+directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
-visible results. For instance, sys.modules
starts with more entries.
-
IDLE also replaces sys.stdin
, sys.stdout
, and sys.stderr
with
-objects that get input from and send output to the Shell window.
-When Shell has the focus, it controls the keyboard and screen. This is
+visible results. For instance, sys.modules
starts with more entries,
+and threading.activeCount()
returns 2 instead of 1.
+
By default, IDLE runs user code in a separate OS process rather than in
+the user interface process that runs the shell and editor. In the execution
+process, it replaces sys.stdin
, sys.stdout
, and sys.stderr
+with objects that get input from and send output to the Shell window.
+The original values stored in sys.__stdin__
, sys.__stdout__
, and
+sys.__stderr__
are not touched, but may be None
.
+
When Shell has the focus, it controls the keyboard and screen. This is
normally transparent, but functions that directly access the keyboard
-and screen will not work. If sys
is reset with importlib.reload(sys)
,
-IDLE?s changes are lost and things like input
, raw_input
, and
-print
will not work correctly.
-
With IDLE?s Shell, one enters, edits, and recalls complete statements.
-Some consoles only work with a single physical line at a time. IDLE uses
-exec
to run each statement. As a result, '__builtins__'
is always
-defined for each statement.
+and screen will not work. These include system-specific functions that
+determine whether a key has been pressed and if so, which.
+
IDLE?s standard stream replacements are not inherited by subprocesses
+created in the execution process, whether directly by user code or by modules
+such as multiprocessing. If such subprocess use input
from sys.stdin
+or print
or write
to sys.stdout or sys.stderr,
+IDLE should be started in a command line window. The secondary subprocess
+will then be attached to that window for input and output.
+
If sys
is reset by user code, such as with importlib.reload(sys)
,
+IDLE?s changes are lost and input from the keyboard and output to the screen
+will not work correctly.
Developing tkinter applications
@@ -752,7 +762,7 @@
Startup and code execution
@@ -841,7 +851,7 @@ Navigation
- Last updated on Oct 28, 2018.
+ Last updated on Nov 05, 2018.
Found a bug?
From webhook-mailer at python.org Mon Nov 5 23:29:12 2018
From: webhook-mailer at python.org (Benjamin Peterson)
Date: Tue, 06 Nov 2018 04:29:12 -0000
Subject: [Python-checkins] closes bpo-35171: Fix
test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
Message-ID:
https://github.com/python/cpython/commit/f1b9ad3d38c11676b45edcbf2369239bae436e56
commit: f1b9ad3d38c11676b45edcbf2369239bae436e56
branch: master
author: Alexey Izbyshev
committer: Benjamin Peterson
date: 2018-11-05T20:29:07-08:00
summary:
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
The test depended on '/usr/share/zoneinfo/posixrules' or equivalent
because it set TZ without explicit DST transition rules. At least
on OpenSUSE Tumbleweed that file is linked to '/etc/localtime',
making the test fail with certain local timezones,
such as 'Europe/Moscow' which doesn't have DST transitions since 2011.
files:
M Lib/test/test_strptime.py
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index a3358a493e53..623da401eee4 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -692,7 +692,7 @@ def test_TimeRE_recreation_locale(self):
finally:
locale.setlocale(locale.LC_TIME, locale_info)
- @support.run_with_tz('STD-1DST')
+ @support.run_with_tz('STD-1DST,M4.1.0,M10.1.0')
def test_TimeRE_recreation_timezone(self):
# The TimeRE instance should be recreated upon changing the timezone.
oldtzname = time.tzname
From webhook-mailer at python.org Mon Nov 5 23:47:14 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 04:47:14 -0000
Subject: [Python-checkins] closes bpo-35171: Fix
test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
Message-ID:
https://github.com/python/cpython/commit/ca592bcf56fca93210331327777fe20fdeff985a
commit: ca592bcf56fca93210331327777fe20fdeff985a
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T20:47:11-08:00
summary:
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
The test depended on '/usr/share/zoneinfo/posixrules' or equivalent
because it set TZ without explicit DST transition rules. At least
on OpenSUSE Tumbleweed that file is linked to '/etc/localtime',
making the test fail with certain local timezones,
such as 'Europe/Moscow' which doesn't have DST transitions since 2011.
(cherry picked from commit f1b9ad3d38c11676b45edcbf2369239bae436e56)
Co-authored-by: Alexey Izbyshev
files:
M Lib/test/test_strptime.py
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index a3358a493e53..623da401eee4 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -692,7 +692,7 @@ def test_TimeRE_recreation_locale(self):
finally:
locale.setlocale(locale.LC_TIME, locale_info)
- @support.run_with_tz('STD-1DST')
+ @support.run_with_tz('STD-1DST,M4.1.0,M10.1.0')
def test_TimeRE_recreation_timezone(self):
# The TimeRE instance should be recreated upon changing the timezone.
oldtzname = time.tzname
From webhook-mailer at python.org Mon Nov 5 23:50:07 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 04:50:07 -0000
Subject: [Python-checkins] closes bpo-35171: Fix
test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
Message-ID:
https://github.com/python/cpython/commit/d0e3105f7ca3fc54b167edc756ce545cbab0ce95
commit: d0e3105f7ca3fc54b167edc756ce545cbab0ce95
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T20:50:04-08:00
summary:
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
The test depended on '/usr/share/zoneinfo/posixrules' or equivalent
because it set TZ without explicit DST transition rules. At least
on OpenSUSE Tumbleweed that file is linked to '/etc/localtime',
making the test fail with certain local timezones,
such as 'Europe/Moscow' which doesn't have DST transitions since 2011.
(cherry picked from commit f1b9ad3d38c11676b45edcbf2369239bae436e56)
Co-authored-by: Alexey Izbyshev
files:
M Lib/test/test_strptime.py
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 1438487161f9..92de8110bc6d 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -641,7 +641,7 @@ def test_TimeRE_recreation_locale(self):
finally:
locale.setlocale(locale.LC_TIME, locale_info)
- @support.run_with_tz('STD-1DST')
+ @support.run_with_tz('STD-1DST,M4.1.0,M10.1.0')
def test_TimeRE_recreation_timezone(self):
# The TimeRE instance should be recreated upon changing the timezone.
oldtzname = time.tzname
From webhook-mailer at python.org Mon Nov 5 23:59:10 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 04:59:10 -0000
Subject: [Python-checkins] closes bpo-35171: Fix
test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
Message-ID:
https://github.com/python/cpython/commit/ffbce43c1aa457b5976665eb2e47771198c7af06
commit: ffbce43c1aa457b5976665eb2e47771198c7af06
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-05T20:59:07-08:00
summary:
closes bpo-35171: Fix test_TimeRE_recreation_timezone failure on some systems. (GH-10347)
The test depended on '/usr/share/zoneinfo/posixrules' or equivalent
because it set TZ without explicit DST transition rules. At least
on OpenSUSE Tumbleweed that file is linked to '/etc/localtime',
making the test fail with certain local timezones,
such as 'Europe/Moscow' which doesn't have DST transitions since 2011.
(cherry picked from commit f1b9ad3d38c11676b45edcbf2369239bae436e56)
Co-authored-by: Alexey Izbyshev
files:
M Lib/test/test_strptime.py
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 48ad5daec402..a7af85a6d556 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -580,7 +580,7 @@ def test_TimeRE_recreation_locale(self):
finally:
locale.setlocale(locale.LC_TIME, locale_info)
- @support.run_with_tz('STD-1DST')
+ @support.run_with_tz('STD-1DST,M4.1.0,M10.1.0')
def test_TimeRE_recreation_timezone(self):
# The TimeRE instance should be recreated upon changing the timezone.
oldtzname = time.tzname
From solipsis at pitrou.net Tue Nov 6 04:11:09 2018
From: solipsis at pitrou.net (solipsis at pitrou.net)
Date: Tue, 06 Nov 2018 09:11:09 +0000
Subject: [Python-checkins] Daily reference leaks (4243df51fe43): sum=11
Message-ID: <20181106091109.1.54D52DBFE7FA1F0B@psf.io>
results for 4243df51fe43 on branch "default"
--------------------------------------------
test_collections leaked [0, 0, 7] memory blocks, sum=7
test_functools leaked [0, 3, 1] memory blocks, sum=4
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogRPCjVN', '--timeout', '7200']
From webhook-mailer at python.org Tue Nov 6 09:59:58 2018
From: webhook-mailer at python.org (Victor Stinner)
Date: Tue, 06 Nov 2018 14:59:58 -0000
Subject: [Python-checkins] bpo-35081: Add _PyCoreConfig_AsDict() (GH-10362)
Message-ID:
https://github.com/python/cpython/commit/5ed6995675b084fe583b71f96fdde4413bb2a77b
commit: 5ed6995675b084fe583b71f96fdde4413bb2a77b
branch: master
author: Victor Stinner
committer: GitHub
date: 2018-11-06T15:59:52+01:00
summary:
bpo-35081: Add _PyCoreConfig_AsDict() (GH-10362)
_testcapimodule.c must not include pycore_pathconfig.h, since it's an
internal header files.
Changes:
* Add _PyCoreConfig_AsDict() function to coreconfig.c.
* Remove pycore_pathconfig.h include from _testcapimodule.h.
* pycore_pathconfig.h now requires Py_BUILD_CORE to be defined.
* _testcapimodule.c compilation now fails if it's built with
Py_BUILD_CORE defined.
files:
M Include/coreconfig.h
M Include/internal/pycore_pathconfig.h
M Modules/_testcapimodule.c
M Python/coreconfig.c
diff --git a/Include/coreconfig.h b/Include/coreconfig.h
index ff7b684a1fa5..a7d3983d4d18 100644
--- a/Include/coreconfig.h
+++ b/Include/coreconfig.h
@@ -358,9 +358,10 @@ PyAPI_FUNC(int) _PyCoreConfig_GetEnvDup(
wchar_t **dest,
wchar_t *wname,
char *name);
-#endif
-
+/* Used by _testcapi.get_coreconfig() */
+PyAPI_FUNC(PyObject *) _PyCoreConfig_AsDict(const _PyCoreConfig *config);
+#endif
#ifdef __cplusplus
}
diff --git a/Include/internal/pycore_pathconfig.h b/Include/internal/pycore_pathconfig.h
index 395df498a0dc..00d7bbf23ea4 100644
--- a/Include/internal/pycore_pathconfig.h
+++ b/Include/internal/pycore_pathconfig.h
@@ -4,6 +4,10 @@
extern "C" {
#endif
+#ifndef Py_BUILD_CORE
+# error "Py_BUILD_CORE must be defined to include this header"
+#endif
+
PyAPI_FUNC(void) _Py_wstrlist_clear(
int len,
wchar_t **list);
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index e2deb2603da8..3133d2b11f81 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -10,7 +10,6 @@
#include "Python.h"
#include "datetime.h"
#include "marshal.h"
-#include "pycore_pathconfig.h"
#include "pythread.h"
#include "structmember.h"
#include
@@ -24,6 +23,10 @@
#include /* For W_STOPCODE */
#endif
+#ifdef Py_BUILD_CORE
+# error "_testcapi must test the public Python C API, not CPython internal C API"
+#endif
+
static PyObject *TestError; /* set to exception object in init */
/* Raise TestError with test_name + ": " + msg, and return NULL. */
@@ -4670,152 +4673,7 @@ get_coreconfig(PyObject *self, PyObject *Py_UNUSED(args))
{
PyInterpreterState *interp = _PyInterpreterState_Get();
const _PyCoreConfig *config = &interp->core_config;
- PyObject *dict, *obj;
-
- dict = PyDict_New();
- if (dict == NULL) {
- return NULL;
- }
-
-#define FROM_STRING(STR) \
- ((STR != NULL) ? \
- PyUnicode_FromString(STR) \
- : (Py_INCREF(Py_None), Py_None))
-#define FROM_WSTRING(STR) \
- ((STR != NULL) ? \
- PyUnicode_FromWideChar(STR, -1) \
- : (Py_INCREF(Py_None), Py_None))
-#define SET_ITEM(KEY, EXPR) \
- do { \
- obj = (EXPR); \
- if (obj == NULL) { \
- return NULL; \
- } \
- int res = PyDict_SetItemString(dict, (KEY), obj); \
- Py_DECREF(obj); \
- if (res < 0) { \
- goto fail; \
- } \
- } while (0)
-
- SET_ITEM("install_signal_handlers",
- PyLong_FromLong(config->install_signal_handlers));
- SET_ITEM("use_environment",
- PyLong_FromLong(config->use_environment));
- SET_ITEM("use_hash_seed",
- PyLong_FromLong(config->use_hash_seed));
- SET_ITEM("hash_seed",
- PyLong_FromUnsignedLong(config->hash_seed));
- SET_ITEM("allocator",
- FROM_STRING(config->allocator));
- SET_ITEM("dev_mode",
- PyLong_FromLong(config->dev_mode));
- SET_ITEM("faulthandler",
- PyLong_FromLong(config->faulthandler));
- SET_ITEM("tracemalloc",
- PyLong_FromLong(config->tracemalloc));
- SET_ITEM("import_time",
- PyLong_FromLong(config->import_time));
- SET_ITEM("show_ref_count",
- PyLong_FromLong(config->show_ref_count));
- SET_ITEM("show_alloc_count",
- PyLong_FromLong(config->show_alloc_count));
- SET_ITEM("dump_refs",
- PyLong_FromLong(config->dump_refs));
- SET_ITEM("malloc_stats",
- PyLong_FromLong(config->malloc_stats));
- SET_ITEM("coerce_c_locale",
- PyLong_FromLong(config->coerce_c_locale));
- SET_ITEM("coerce_c_locale_warn",
- PyLong_FromLong(config->coerce_c_locale_warn));
- SET_ITEM("filesystem_encoding",
- FROM_STRING(config->filesystem_encoding));
- SET_ITEM("filesystem_errors",
- FROM_STRING(config->filesystem_errors));
- SET_ITEM("stdio_encoding",
- FROM_STRING(config->stdio_encoding));
- SET_ITEM("utf8_mode",
- PyLong_FromLong(config->utf8_mode));
- SET_ITEM("pycache_prefix",
- FROM_WSTRING(config->pycache_prefix));
- SET_ITEM("program_name",
- FROM_WSTRING(config->program_name));
- SET_ITEM("argv",
- _Py_wstrlist_as_pylist(config->argc, config->argv));
- SET_ITEM("program",
- FROM_WSTRING(config->program));
- SET_ITEM("warnoptions",
- _Py_wstrlist_as_pylist(config->nwarnoption, config->warnoptions));
- SET_ITEM("module_search_path_env",
- FROM_WSTRING(config->module_search_path_env));
- SET_ITEM("home",
- FROM_WSTRING(config->home));
- SET_ITEM("module_search_paths",
- _Py_wstrlist_as_pylist(config->nmodule_search_path, config->module_search_paths));
- SET_ITEM("executable",
- FROM_WSTRING(config->executable));
- SET_ITEM("prefix",
- FROM_WSTRING(config->prefix));
- SET_ITEM("base_prefix",
- FROM_WSTRING(config->base_prefix));
- SET_ITEM("exec_prefix",
- FROM_WSTRING(config->exec_prefix));
- SET_ITEM("base_exec_prefix",
- FROM_WSTRING(config->base_exec_prefix));
-#ifdef MS_WINDOWS
- SET_ITEM("dll_path",
- FROM_WSTRING(config->dll_path));
-#endif
- SET_ITEM("isolated",
- PyLong_FromLong(config->isolated));
- SET_ITEM("site_import",
- PyLong_FromLong(config->site_import));
- SET_ITEM("bytes_warning",
- PyLong_FromLong(config->bytes_warning));
- SET_ITEM("inspect",
- PyLong_FromLong(config->inspect));
- SET_ITEM("interactive",
- PyLong_FromLong(config->interactive));
- SET_ITEM("optimization_level",
- PyLong_FromLong(config->optimization_level));
- SET_ITEM("parser_debug",
- PyLong_FromLong(config->parser_debug));
- SET_ITEM("write_bytecode",
- PyLong_FromLong(config->write_bytecode));
- SET_ITEM("verbose",
- PyLong_FromLong(config->verbose));
- SET_ITEM("quiet",
- PyLong_FromLong(config->quiet));
- SET_ITEM("user_site_directory",
- PyLong_FromLong(config->user_site_directory));
- SET_ITEM("buffered_stdio",
- PyLong_FromLong(config->buffered_stdio));
- SET_ITEM("stdio_encoding",
- FROM_STRING(config->stdio_encoding));
- SET_ITEM("stdio_errors",
- FROM_STRING(config->stdio_errors));
-#ifdef MS_WINDOWS
- SET_ITEM("legacy_windows_fs_encoding",
- PyLong_FromLong(config->legacy_windows_fs_encoding));
- SET_ITEM("legacy_windows_stdio",
- PyLong_FromLong(config->legacy_windows_stdio));
-#endif
- SET_ITEM("_install_importlib",
- PyLong_FromLong(config->_install_importlib));
- SET_ITEM("_check_hash_pycs_mode",
- FROM_STRING(config->_check_hash_pycs_mode));
- SET_ITEM("_frozen",
- PyLong_FromLong(config->_frozen));
-
- return dict;
-
-fail:
- Py_DECREF(dict);
- return NULL;
-
-#undef FROM_STRING
-#undef FROM_WSTRING
-#undef SET_ITEM
+ return _PyCoreConfig_AsDict(config);
}
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index b21e9344cd16..b6fc33c3c96b 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1358,3 +1358,155 @@ _PyCoreConfig_Read(_PyCoreConfig *config)
return _Py_INIT_OK();
}
+
+
+PyObject *
+_PyCoreConfig_AsDict(const _PyCoreConfig *config)
+{
+ PyObject *dict, *obj;
+
+ dict = PyDict_New();
+ if (dict == NULL) {
+ return NULL;
+ }
+
+#define FROM_STRING(STR) \
+ ((STR != NULL) ? \
+ PyUnicode_FromString(STR) \
+ : (Py_INCREF(Py_None), Py_None))
+#define FROM_WSTRING(STR) \
+ ((STR != NULL) ? \
+ PyUnicode_FromWideChar(STR, -1) \
+ : (Py_INCREF(Py_None), Py_None))
+#define SET_ITEM(KEY, EXPR) \
+ do { \
+ obj = (EXPR); \
+ if (obj == NULL) { \
+ return NULL; \
+ } \
+ int res = PyDict_SetItemString(dict, (KEY), obj); \
+ Py_DECREF(obj); \
+ if (res < 0) { \
+ goto fail; \
+ } \
+ } while (0)
+
+ SET_ITEM("install_signal_handlers",
+ PyLong_FromLong(config->install_signal_handlers));
+ SET_ITEM("use_environment",
+ PyLong_FromLong(config->use_environment));
+ SET_ITEM("use_hash_seed",
+ PyLong_FromLong(config->use_hash_seed));
+ SET_ITEM("hash_seed",
+ PyLong_FromUnsignedLong(config->hash_seed));
+ SET_ITEM("allocator",
+ FROM_STRING(config->allocator));
+ SET_ITEM("dev_mode",
+ PyLong_FromLong(config->dev_mode));
+ SET_ITEM("faulthandler",
+ PyLong_FromLong(config->faulthandler));
+ SET_ITEM("tracemalloc",
+ PyLong_FromLong(config->tracemalloc));
+ SET_ITEM("import_time",
+ PyLong_FromLong(config->import_time));
+ SET_ITEM("show_ref_count",
+ PyLong_FromLong(config->show_ref_count));
+ SET_ITEM("show_alloc_count",
+ PyLong_FromLong(config->show_alloc_count));
+ SET_ITEM("dump_refs",
+ PyLong_FromLong(config->dump_refs));
+ SET_ITEM("malloc_stats",
+ PyLong_FromLong(config->malloc_stats));
+ SET_ITEM("coerce_c_locale",
+ PyLong_FromLong(config->coerce_c_locale));
+ SET_ITEM("coerce_c_locale_warn",
+ PyLong_FromLong(config->coerce_c_locale_warn));
+ SET_ITEM("filesystem_encoding",
+ FROM_STRING(config->filesystem_encoding));
+ SET_ITEM("filesystem_errors",
+ FROM_STRING(config->filesystem_errors));
+ SET_ITEM("stdio_encoding",
+ FROM_STRING(config->stdio_encoding));
+ SET_ITEM("utf8_mode",
+ PyLong_FromLong(config->utf8_mode));
+ SET_ITEM("pycache_prefix",
+ FROM_WSTRING(config->pycache_prefix));
+ SET_ITEM("program_name",
+ FROM_WSTRING(config->program_name));
+ SET_ITEM("argv",
+ _Py_wstrlist_as_pylist(config->argc, config->argv));
+ SET_ITEM("program",
+ FROM_WSTRING(config->program));
+ SET_ITEM("warnoptions",
+ _Py_wstrlist_as_pylist(config->nwarnoption, config->warnoptions));
+ SET_ITEM("module_search_path_env",
+ FROM_WSTRING(config->module_search_path_env));
+ SET_ITEM("home",
+ FROM_WSTRING(config->home));
+ SET_ITEM("module_search_paths",
+ _Py_wstrlist_as_pylist(config->nmodule_search_path, config->module_search_paths));
+ SET_ITEM("executable",
+ FROM_WSTRING(config->executable));
+ SET_ITEM("prefix",
+ FROM_WSTRING(config->prefix));
+ SET_ITEM("base_prefix",
+ FROM_WSTRING(config->base_prefix));
+ SET_ITEM("exec_prefix",
+ FROM_WSTRING(config->exec_prefix));
+ SET_ITEM("base_exec_prefix",
+ FROM_WSTRING(config->base_exec_prefix));
+#ifdef MS_WINDOWS
+ SET_ITEM("dll_path",
+ FROM_WSTRING(config->dll_path));
+#endif
+ SET_ITEM("isolated",
+ PyLong_FromLong(config->isolated));
+ SET_ITEM("site_import",
+ PyLong_FromLong(config->site_import));
+ SET_ITEM("bytes_warning",
+ PyLong_FromLong(config->bytes_warning));
+ SET_ITEM("inspect",
+ PyLong_FromLong(config->inspect));
+ SET_ITEM("interactive",
+ PyLong_FromLong(config->interactive));
+ SET_ITEM("optimization_level",
+ PyLong_FromLong(config->optimization_level));
+ SET_ITEM("parser_debug",
+ PyLong_FromLong(config->parser_debug));
+ SET_ITEM("write_bytecode",
+ PyLong_FromLong(config->write_bytecode));
+ SET_ITEM("verbose",
+ PyLong_FromLong(config->verbose));
+ SET_ITEM("quiet",
+ PyLong_FromLong(config->quiet));
+ SET_ITEM("user_site_directory",
+ PyLong_FromLong(config->user_site_directory));
+ SET_ITEM("buffered_stdio",
+ PyLong_FromLong(config->buffered_stdio));
+ SET_ITEM("stdio_encoding",
+ FROM_STRING(config->stdio_encoding));
+ SET_ITEM("stdio_errors",
+ FROM_STRING(config->stdio_errors));
+#ifdef MS_WINDOWS
+ SET_ITEM("legacy_windows_fs_encoding",
+ PyLong_FromLong(config->legacy_windows_fs_encoding));
+ SET_ITEM("legacy_windows_stdio",
+ PyLong_FromLong(config->legacy_windows_stdio));
+#endif
+ SET_ITEM("_install_importlib",
+ PyLong_FromLong(config->_install_importlib));
+ SET_ITEM("_check_hash_pycs_mode",
+ FROM_STRING(config->_check_hash_pycs_mode));
+ SET_ITEM("_frozen",
+ PyLong_FromLong(config->_frozen));
+
+ return dict;
+
+fail:
+ Py_DECREF(dict);
+ return NULL;
+
+#undef FROM_STRING
+#undef FROM_WSTRING
+#undef SET_ITEM
+}
From webhook-mailer at python.org Tue Nov 6 12:37:42 2018
From: webhook-mailer at python.org (Terry Jan Reedy)
Date: Tue, 06 Nov 2018 17:37:42 -0000
Subject: [Python-checkins] bpo-23220: Explain how IDLE's Shell displays
output (GH-10356)
Message-ID:
https://github.com/python/cpython/commit/75d9d59ab3a372d3d78e6a1f5e9f256e29d0a9a6
commit: 75d9d59ab3a372d3d78e6a1f5e9f256e29d0a9a6
branch: master
author: Terry Jan Reedy
committer: GitHub
date: 2018-11-06T12:37:36-05:00
summary:
bpo-23220: Explain how IDLE's Shell displays output (GH-10356)
Add a new subsection to the doc.
files:
A Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
M Doc/library/idle.rst
M Lib/idlelib/help.html
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index c5015bf30cfb..fa58e2d59421 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -502,8 +502,16 @@ or immediately run an existing file before editing.
Python Shell window
^^^^^^^^^^^^^^^^^^^
-The editing features described above work when entering code interactively.
-IDLE's Shell window also responds to the following keys.
+With IDLE's Shell, one enters, edits, and recalls complete statements.
+Most consoles and terminals only work with a single physical line at a time.
+
+When one pastes code into Shell, it is not compiled and possibly executed
+until one hits :kbd:`Return`. One may edit pasted code first.
+If one pastes more that one statement into Shell, the result will be a
+:exc:`SyntaxError` when multiple statements are compiled as if they were one.
+
+The editing features described in previous subsections work when entering
+code interactively. IDLE's Shell window also responds to the following keys.
* :kbd:`C-c` interrupts executing command
@@ -520,16 +528,6 @@ IDLE's Shell window also responds to the following keys.
* :kbd:`Return` while on any previous command retrieves that command
-Shell has a special facility for squeezing output lines down to a
-'Squeezed text' label. This is done automatically for output over N lines
-(N = 50 by default). N can be changed in the PyShell section of the General
-page of the Settings dialog. Output with fewer lines can be squeezed by
-right clicking on the output. This can be useful for extra long lines.
-
-Squeezed output is expanded in place by double-clicking the label.
-It can also be sent to the clipboard or a separate view window by
-right-clicking the label.
-
Text colors
^^^^^^^^^^^
@@ -666,6 +664,44 @@ If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
IDLE's changes are lost and input from the keyboard and output to the screen
will not work correctly.
+User output in Shell
+^^^^^^^^^^^^^^^^^^^^
+
+When a program outputs text, the result is determined by the
+corresponding output device. When IDLE executes user code, ``sys.stdout``
+and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of
+its features are inherited from the underlying Tk Text widget. Others
+are programmed additions.
+
+Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
+Which characters get a proper glyph instead of a replacement box depends on
+the operating system and installed fonts. Newline characters cause following
+text to appear on a new line, but other control characters are replaced
+with a box. But note that the ``repr()`` function, which is used for
+interactive echo of expression values, replaces control characters
+with escape codes before they are output.
+
+Normal and error output are generally kept separate (on separate lines)
+from code input and each other. They each get different highlight colors.
+
+For SyntaxError tracebacks, the normal '^' marking where the error was
+detected is replaced by coloring the text with an error highlight.
+When code run from a file causes other exceptions, one may right click
+on a traceback line to jump to the corresponding line in an IDLE editor.
+The file will be opened if necessary.
+
+Shell has a special facility for squeezing output lines down to a
+'Squeezed text' label. This is done automatically
+for output over N lines (N = 50 by default).
+N can be changed in the PyShell section of the General
+page of the Settings dialog. Output with fewer lines can be squeezed by
+right clicking on the output. This can be useful lines long enough to slow
+down scrolling.
+
+Squeezed output is expanded in place by double-clicking the label.
+It can also be sent to the clipboard or a separate view window by
+right-clicking the label.
+
Developing tkinter applications
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 1cd9b6913de8..83bd4a1b91df 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -501,8 +501,14 @@ Calltips
Developing tkinter applications
IDLE is intentionally different from standard Python in order to
@@ -763,6 +793,7 @@
Command line usage
Startup failure
Running user code
+
User output in Shell
Developing tkinter applications
Running without a subprocess
@@ -851,7 +882,7 @@
Navigation
- Last updated on Nov 05, 2018.
+ Last updated on Nov 06, 2018.
Found a bug?
diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
new file mode 100644
index 000000000000..77c71268dddd
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
@@ -0,0 +1 @@
+Explain how IDLE's Shell displays output.
From webhook-mailer at python.org Tue Nov 6 13:27:24 2018
From: webhook-mailer at python.org (Miss Islington (bot))
Date: Tue, 06 Nov 2018 18:27:24 -0000
Subject: [Python-checkins] bpo-23220: Explain how IDLE's Shell displays
output (GH-10356)
Message-ID:
https://github.com/python/cpython/commit/34fcee9ed81c954d6418241ad546f71e103d3b9b
commit: 34fcee9ed81c954d6418241ad546f71e103d3b9b
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub
date: 2018-11-06T10:27:20-08:00
summary:
bpo-23220: Explain how IDLE's Shell displays output (GH-10356)
Add a new subsection to the doc.
(cherry picked from commit 75d9d59ab3a372d3d78e6a1f5e9f256e29d0a9a6)
Co-authored-by: Terry Jan Reedy
files:
A Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
M Doc/library/idle.rst
M Lib/idlelib/help.html
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index c5015bf30cfb..fa58e2d59421 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -502,8 +502,16 @@ or immediately run an existing file before editing.
Python Shell window
^^^^^^^^^^^^^^^^^^^
-The editing features described above work when entering code interactively.
-IDLE's Shell window also responds to the following keys.
+With IDLE's Shell, one enters, edits, and recalls complete statements.
+Most consoles and terminals only work with a single physical line at a time.
+
+When one pastes code into Shell, it is not compiled and possibly executed
+until one hits :kbd:`Return`. One may edit pasted code first.
+If one pastes more that one statement into Shell, the result will be a
+:exc:`SyntaxError` when multiple statements are compiled as if they were one.
+
+The editing features described in previous subsections work when entering
+code interactively. IDLE's Shell window also responds to the following keys.
* :kbd:`C-c` interrupts executing command
@@ -520,16 +528,6 @@ IDLE's Shell window also responds to the following keys.
* :kbd:`Return` while on any previous command retrieves that command
-Shell has a special facility for squeezing output lines down to a
-'Squeezed text' label. This is done automatically for output over N lines
-(N = 50 by default). N can be changed in the PyShell section of the General
-page of the Settings dialog. Output with fewer lines can be squeezed by
-right clicking on the output. This can be useful for extra long lines.
-
-Squeezed output is expanded in place by double-clicking the label.
-It can also be sent to the clipboard or a separate view window by
-right-clicking the label.
-
Text colors
^^^^^^^^^^^
@@ -666,6 +664,44 @@ If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
IDLE's changes are lost and input from the keyboard and output to the screen
will not work correctly.
+User output in Shell
+^^^^^^^^^^^^^^^^^^^^
+
+When a program outputs text, the result is determined by the
+corresponding output device. When IDLE executes user code, ``sys.stdout``
+and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of
+its features are inherited from the underlying Tk Text widget. Others
+are programmed additions.
+
+Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
+Which characters get a proper glyph instead of a replacement box depends on
+the operating system and installed fonts. Newline characters cause following
+text to appear on a new line, but other control characters are replaced
+with a box. But note that the ``repr()`` function, which is used for
+interactive echo of expression values, replaces control characters
+with escape codes before they are output.
+
+Normal and error output are generally kept separate (on separate lines)
+from code input and each other. They each get different highlight colors.
+
+For SyntaxError tracebacks, the normal '^' marking where the error was
+detected is replaced by coloring the text with an error highlight.
+When code run from a file causes other exceptions, one may right click
+on a traceback line to jump to the corresponding line in an IDLE editor.
+The file will be opened if necessary.
+
+Shell has a special facility for squeezing output lines down to a
+'Squeezed text' label. This is done automatically
+for output over N lines (N = 50 by default).
+N can be changed in the PyShell section of the General
+page of the Settings dialog. Output with fewer lines can be squeezed by
+right clicking on the output. This can be useful lines long enough to slow
+down scrolling.
+
+Squeezed output is expanded in place by double-clicking the label.
+It can also be sent to the clipboard or a separate view window by
+right-clicking the label.
+
Developing tkinter applications
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 1cd9b6913de8..83bd4a1b91df 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -501,8 +501,14 @@ Calltips
Developing tkinter applications
IDLE is intentionally different from standard Python in order to
@@ -763,6 +793,7 @@
Command line usage
Startup failure
Running user code
+
User output in Shell
Developing tkinter applications
Running without a subprocess
@@ -851,7 +882,7 @@
Navigation
- Last updated on Nov 05, 2018.
+ Last updated on Nov 06, 2018.
Found a bug?
diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
new file mode 100644
index 000000000000..77c71268dddd
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
@@ -0,0 +1 @@
+Explain how IDLE's Shell displays output.
From webhook-mailer at python.org Tue Nov 6 13:59:44 2018
From: webhook-mailer at python.org (Terry Jan Reedy)
Date: Tue, 06 Nov 2018 18:59:44 -0000
Subject: [Python-checkins] bpo-23220: Explain how IDLE's Shell displays
output (GH-10356) (#10369)
Message-ID:
https://github.com/python/cpython/commit/7476fefb65075161d57435c8dd7e92437578d3c1
commit: 7476fefb65075161d57435c8dd7e92437578d3c1
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Terry Jan Reedy
date: 2018-11-06T13:59:39-05:00
summary:
bpo-23220: Explain how IDLE's Shell displays output (GH-10356) (#10369)
Add a new subsection to the doc.
(cherry picked from commit 75d9d59ab3a372d3d78e6a1f5e9f256e29d0a9a6)
Co-authored-by: Terry Jan Reedy
files:
A Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
M Doc/library/idle.rst
M Lib/idlelib/help.html
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index a4432190bbb0..44085e172d47 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -502,8 +502,16 @@ or immediately run an existing file before editing.
Python Shell window
^^^^^^^^^^^^^^^^^^^
-The editing features described above work when entering code interactively.
-IDLE's Shell window also responds to the following keys.
+With IDLE's Shell, one enters, edits, and recalls complete statements.
+Most consoles and terminals only work with a single physical line at a time.
+
+When one pastes code into Shell, it is not compiled and possibly executed
+until one hits :kbd:`Return`. One may edit pasted code first.
+If one pastes more that one statement into Shell, the result will be a
+:exc:`SyntaxError` when multiple statements are compiled as if they were one.
+
+The editing features described in previous subsections work when entering
+code interactively. IDLE's Shell window also responds to the following keys.
* :kbd:`C-c` interrupts executing command
@@ -520,16 +528,6 @@ IDLE's Shell window also responds to the following keys.
* :kbd:`Return` while on any previous command retrieves that command
-Shell has a special facility for squeezing output lines down to a
-'Squeezed text' label. This is done automatically for output over N lines
-(N = 50 by default). N can be changed in the PyShell section of the General
-page of the Settings dialog. Output with fewer lines can be squeezed by
-right clicking on the output. This can be useful for extra long lines.
-
-Squeezed output is expanded in place by double-clicking the label.
-It can also be sent to the clipboard or a separate view window by
-right-clicking the label.
-
Text colors
^^^^^^^^^^^
@@ -666,6 +664,44 @@ If ``sys`` is reset by user code, such as with ``importlib.reload(sys)``,
IDLE's changes are lost and input from the keyboard and output to the screen
will not work correctly.
+User output in Shell
+^^^^^^^^^^^^^^^^^^^^
+
+When a program outputs text, the result is determined by the
+corresponding output device. When IDLE executes user code, ``sys.stdout``
+and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of
+its features are inherited from the underlying Tk Text widget. Others
+are programmed additions.
+
+Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
+Which characters get a proper glyph instead of a replacement box depends on
+the operating system and installed fonts. Newline characters cause following
+text to appear on a new line, but other control characters are replaced
+with a box. But note that the ``repr()`` function, which is used for
+interactive echo of expression values, replaces control characters
+with escape codes before they are output.
+
+Normal and error output are generally kept separate (on separate lines)
+from code input and each other. They each get different highlight colors.
+
+For SyntaxError tracebacks, the normal '^' marking where the error was
+detected is replaced by coloring the text with an error highlight.
+When code run from a file causes other exceptions, one may right click
+on a traceback line to jump to the corresponding line in an IDLE editor.
+The file will be opened if necessary.
+
+Shell has a special facility for squeezing output lines down to a
+'Squeezed text' label. This is done automatically
+for output over N lines (N = 50 by default).
+N can be changed in the PyShell section of the General
+page of the Settings dialog. Output with fewer lines can be squeezed by
+right clicking on the output. This can be useful lines long enough to slow
+down scrolling.
+
+Squeezed output is expanded in place by double-clicking the label.
+It can also be sent to the clipboard or a separate view window by
+right-clicking the label.
+
Developing tkinter applications
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 1cd9b6913de8..83bd4a1b91df 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -501,8 +501,14 @@ Calltips
Developing tkinter applications
IDLE is intentionally different from standard Python in order to
@@ -763,6 +793,7 @@
Command line usage
Startup failure
Running user code
+
User output in Shell
Developing tkinter applications
Running without a subprocess
@@ -851,7 +882,7 @@
Navigation
- Last updated on Nov 05, 2018.
+ Last updated on Nov 06, 2018.
Found a bug?
diff --git a/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
new file mode 100644
index 000000000000..77c71268dddd
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-11-05-23-23-00.bpo-23220.H3SAWE.rst
@@ -0,0 +1 @@
+Explain how IDLE's Shell displays output.
From webhook-mailer at python.org Tue Nov 6 14:38:42 2018
From: webhook-mailer at python.org (Antoine Pitrou)
Date: Tue, 06 Nov 2018 19:38:42 -0000
Subject: [Python-checkins] bpo-17560: Too small type for struct.pack/unpack
in mutliprocessing.Connection (GH-10305)
Message-ID:
https://github.com/python/cpython/commit/bccacd19fa7b56dcf2fbfab15992b6b94ab6666b
commit: bccacd19fa7b56dcf2fbfab15992b6b94ab6666b
branch: master
author: Alexander Buchkovsky
committer: Antoine Pitrou
date: 2018-11-06T20:38:34+01:00
summary:
bpo-17560: Too small type for struct.pack/unpack in mutliprocessing.Connection (GH-10305)
Allow sending more than 2 GB at once on a multiprocessing connection on non-Windows systems.
files:
A Misc/NEWS.d/next/Library/2018-11-03-10-12-04.bpo-35152.xpqskp.rst
M Lib/multiprocessing/connection.py
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
index 1f3ea504fff4..c9f995e5fa7f 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -389,23 +389,33 @@ def _recv(self, size, read=_read):
def _send_bytes(self, buf):
n = len(buf)
- # For wire compatibility with 3.2 and lower
- header = struct.pack("!i", n)
- if n > 16384:
- # The payload is large so Nagle's algorithm won't be triggered
- # and we'd better avoid the cost of concatenation.
+ if n > 0x7fffffff:
+ pre_header = struct.pack("!i", -1)
+ header = struct.pack("!Q", n)
+ self._send(pre_header)
self._send(header)
self._send(buf)
else:
- # Issue #20540: concatenate before sending, to avoid delays due
- # to Nagle's algorithm on a TCP socket.
- # Also note we want to avoid sending a 0-length buffer separately,
- # to avoid "broken pipe" errors if the other end closed the pipe.
- self._send(header + buf)
+ # For wire compatibility with 3.7 and lower
+ header = struct.pack("!i", n)
+ if n > 16384:
+ # The payload is large so Nagle's algorithm won't be triggered
+ # and we'd better avoid the cost of concatenation.
+ self._send(header)
+ self._send(buf)
+ else:
+ # Issue #20540: concatenate before sending, to avoid delays due
+ # to Nagle's algorithm on a TCP socket.
+ # Also note we want to avoid sending a 0-length buffer separately,
+ # to avoid "broken pipe" errors if the other end closed the pipe.
+ self._send(header + buf)
def _recv_bytes(self, maxsize=None):
buf = self._recv(4)
size, = struct.unpack("!i", buf.getvalue())
+ if size == -1:
+ buf = self._recv(8)
+ size, = struct.unpack("!Q", buf.getvalue())
if maxsize is not None and size > maxsize:
return None
return self._recv(size)
diff --git a/Misc/NEWS.d/next/Library/2018-11-03-10-12-04.bpo-35152.xpqskp.rst b/Misc/NEWS.d/next/Library/2018-11-03-10-12-04.bpo-35152.xpqskp.rst
new file mode 100644
index 000000000000..7cc9ed39007e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-11-03-10-12-04.bpo-35152.xpqskp.rst
@@ -0,0 +1 @@
+Allow sending more than 2 GB at once on a multiprocessing connection on non-Windows systems.
\ No newline at end of file
From webhook-mailer at python.org Tue Nov 6 18:44:07 2018
From: webhook-mailer at python.org (Victor Stinner)
Date: Tue, 06 Nov 2018 23:44:07 -0000
Subject: [Python-checkins] bpo-35081: Add pycore_fileutils.h (GH-10371)
Message-ID:
https://github.com/python/cpython/commit/9fc57a384825530635ef5ec093a31d864ea14f7c
commit: 9fc57a384825530635ef5ec093a31d864ea14f7c
branch: master
author: Victor Stinner
committer: GitHub
date: 2018-11-07T00:44:03+01:00
summary:
bpo-35081: Add pycore_fileutils.h (GH-10371)
Move Py_BUILD_CORE code from Include/fileutils.h to a new
Include/internal/pycore_fileutils.h file.
files:
A Include/internal/pycore_fileutils.h
M Include/fileutils.h
M Modules/getpath.c
M Objects/unicodeobject.c
M Python/coreconfig.c
M Python/fileutils.c
M Python/pathconfig.c
diff --git a/Include/fileutils.h b/Include/fileutils.h
index 232d9664cdd0..fdd60fffcd55 100644
--- a/Include/fileutils.h
+++ b/Include/fileutils.h
@@ -1,28 +1,9 @@
#ifndef Py_FILEUTILS_H
#define Py_FILEUTILS_H
-
#ifdef __cplusplus
extern "C" {
#endif
-
-#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
-typedef enum {
- _Py_ERROR_UNKNOWN=0,
- _Py_ERROR_STRICT,
- _Py_ERROR_SURROGATEESCAPE,
- _Py_ERROR_REPLACE,
- _Py_ERROR_IGNORE,
- _Py_ERROR_BACKSLASHREPLACE,
- _Py_ERROR_SURROGATEPASS,
- _Py_ERROR_XMLCHARREFREPLACE,
- _Py_ERROR_OTHER
-} _Py_error_handler;
-
-PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors);
-#endif
-
-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
const char *arg,
@@ -37,30 +18,22 @@ PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
size_t *error_pos);
#endif
-#ifdef Py_BUILD_CORE
-PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
- const char *arg,
- Py_ssize_t arglen,
- wchar_t **wstr,
- size_t *wlen,
- const char **reason,
- _Py_error_handler errors);
-
-PyAPI_FUNC(int) _Py_EncodeUTF8Ex(
- const wchar_t *text,
- char **str,
- size_t *error_pos,
- const char **reason,
- int raw_malloc,
- _Py_error_handler errors);
-PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
- const char *arg,
- Py_ssize_t arglen);
-#endif
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
+typedef enum {
+ _Py_ERROR_UNKNOWN=0,
+ _Py_ERROR_STRICT,
+ _Py_ERROR_SURROGATEESCAPE,
+ _Py_ERROR_REPLACE,
+ _Py_ERROR_IGNORE,
+ _Py_ERROR_BACKSLASHREPLACE,
+ _Py_ERROR_SURROGATEPASS,
+ _Py_ERROR_XMLCHARREFREPLACE,
+ _Py_ERROR_OTHER
+} _Py_error_handler;
+PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors);
-#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
PyAPI_FUNC(int) _Py_DecodeLocaleEx(
const char *arg,
wchar_t **wstr,
@@ -204,13 +177,7 @@ PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
#endif /* Py_LIMITED_API */
-
-#ifdef Py_BUILD_CORE
-PyAPI_FUNC(int) _Py_GetForceASCII(void);
-#endif
-
#ifdef __cplusplus
}
#endif
-
#endif /* !Py_FILEUTILS_H */
diff --git a/Include/internal/pycore_fileutils.h b/Include/internal/pycore_fileutils.h
new file mode 100644
index 000000000000..d577e099d1f5
--- /dev/null
+++ b/Include/internal/pycore_fileutils.h
@@ -0,0 +1,36 @@
+#ifndef Py_INTERNAL_FILEUTILS_H
+#define Py_INTERNAL_FILEUTILS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+# error "Py_BUILD_CORE must be defined to include this header"
+#endif
+
+PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
+ const char *arg,
+ Py_ssize_t arglen,
+ wchar_t **wstr,
+ size_t *wlen,
+ const char **reason,
+ _Py_error_handler errors);
+
+PyAPI_FUNC(int) _Py_EncodeUTF8Ex(
+ const wchar_t *text,
+ char **str,
+ size_t *error_pos,
+ const char **reason,
+ int raw_malloc,
+ _Py_error_handler errors);
+
+PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
+ const char *arg,
+ Py_ssize_t arglen);
+
+PyAPI_FUNC(int) _Py_GetForceASCII(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_FILEUTILS_H */
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 0e210710ecf4..6b443f62b054 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -2,6 +2,7 @@
#include "Python.h"
#include "osdefs.h"
+#include "pycore_fileutils.h"
#include "pycore_pathconfig.h"
#include "pycore_state.h"
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3692da64122f..5338781edc2f 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -40,6 +40,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_fileutils.h"
#include "pycore_state.h"
#include "ucnhash.h"
#include "bytes_methods.h"
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index b6fc33c3c96b..c81cd8bab775 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1,4 +1,5 @@
#include "Python.h"
+#include "pycore_fileutils.h"
#include "pycore_lifecycle.h"
#include "pycore_mem.h"
#include "pycore_pathconfig.h"
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 2c4061e2692c..c9a8e58dd122 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1,4 +1,5 @@
#include "Python.h"
+#include "pycore_fileutils.h"
#include "osdefs.h"
#include
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index f8bcc2886a1c..2d8b417d31f7 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -3,6 +3,7 @@
#include "Python.h"
#include "osdefs.h"
#include "pycore_mem.h"
+#include "pycore_fileutils.h"
#include "pycore_pathconfig.h"
#include "pycore_state.h"
#include
From webhook-mailer at python.org Tue Nov 6 23:55:11 2018
From: webhook-mailer at python.org (Terry Jan Reedy)
Date: Wed, 07 Nov 2018 04:55:11 -0000
Subject: [Python-checkins] bpo-33000: Document that IDLE's shell has no line
limit. (#10373)
Message-ID:
https://github.com/python/cpython/commit/76cd0c30d60961d1a10e2673834a455d2b51f695
commit: 76cd0c30d60961d1a10e2673834a455d2b51f695
branch: master
author: Terry Jan Reedy
committer: GitHub
date: 2018-11-06T23:55:06-05:00
summary:
bpo-33000: Document that IDLE's shell has no line limit. (#10373)
A program that runs indefinitely can overfill memory.
files:
A Misc/NEWS.d/next/IDLE/2018-11-06-23-10-54.bpo-33000.pQasCt.rst
M Doc/library/idle.rst
M Lib/idlelib/help.html
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index fa58e2d59421..f353fbc86127 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -671,15 +671,23 @@ When a program outputs text, the result is determined by the
corresponding output device. When IDLE executes user code, ``sys.stdout``
and ``sys.stderr`` are connected to the display area of IDLE's Shell. Some of
its features are inherited from the underlying Tk Text widget. Others
-are programmed additions.
+are programmed additions. Where it matters, Shell is designed for development
+rather than production runs.
+
+For instance, Shell never throws away output. A program that sends unlimited
+output to Shell will eventually fill memory, resulting in a memory error.
+In contrast, some system text windows only keep the last n lines of output.
+A Windows console, for instance, keeps a user-settable 1 to 9999 lines,
+with 300 the default.
Text widgets display a subset of Unicode, the Basic Multilingual Plane (BMP).
Which characters get a proper glyph instead of a replacement box depends on
the operating system and installed fonts. Newline characters cause following
-text to appear on a new line, but other control characters are replaced
-with a box. But note that the ``repr()`` function, which is used for
-interactive echo of expression values, replaces control characters
-with escape codes before they are output.
+text to appear on a new line, but other control characters are either
+replaced with a box or deleted. However, ``repr()``, which is used for
+interactive echo of expression values, replaces control characters,
+some BMP codepoints, and all non-BMP characters with escape codes
+before they are output.
Normal and error output are generally kept separate (on separate lines)
from code input and each other. They each get different highlight colors.
diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html
index 83bd4a1b91df..f0b42151f359 100644
--- a/Lib/idlelib/help.html
+++ b/Lib/idlelib/help.html
@@ -648,14 +648,21 @@ User output in Shell