Thread View
j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
https://github.com/python/cpython/commit/251ffa9d2b16b091046720628deb6a7906…
commit: 251ffa9d2b16b091046720628deb6a7906c35d29
branch: master
author: Ma Lin <animalize(a)users.noreply.github.com>
committer: gpshead <greg(a)krypto.org>
date: 2021-04-30T16:32:49-07:00
summary:
bpo-41486: Fix initial buffer size can't > UINT32_MAX in zlib module (GH-25738)
* Fix initial buffer size can't > UINT32_MAX in zlib module
After commit f9bedb630e8a0b7d94e1c7e609b20dfaa2b22231, in 64-bit build,
if the initial buffer size > UINT32_MAX, ValueError will be raised.
These two functions are affected:
1. zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
2. zlib.Decompress.flush([length])
This commit re-allows the size > UINT32_MAX.
* adds curly braces per PEP 7.
* Renames `Buffer_*` to `OutputBuffer_*` for clarity
files:
M Modules/_bz2module.c
M Modules/_lzmamodule.c
M Modules/zlibmodule.c
diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c
index 9893a63726291..d75bb32d2fc5e 100644
--- a/Modules/_bz2module.c
+++ b/Modules/_bz2module.c
@@ -18,8 +18,8 @@
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
- char **next_out, uint32_t *avail_out)
+OutputBuffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
+ char **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
@@ -32,8 +32,8 @@ Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_Grow(_BlocksOutputBuffer *buffer,
- char **next_out, uint32_t *avail_out)
+OutputBuffer_Grow(_BlocksOutputBuffer *buffer,
+ char **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
@@ -44,19 +44,19 @@ Buffer_Grow(_BlocksOutputBuffer *buffer,
}
static inline Py_ssize_t
-Buffer_GetDataSize(_BlocksOutputBuffer *buffer, uint32_t avail_out)
+OutputBuffer_GetDataSize(_BlocksOutputBuffer *buffer, uint32_t avail_out)
{
return _BlocksOutputBuffer_GetDataSize(buffer, (Py_ssize_t) avail_out);
}
static inline PyObject *
-Buffer_Finish(_BlocksOutputBuffer *buffer, uint32_t avail_out)
+OutputBuffer_Finish(_BlocksOutputBuffer *buffer, uint32_t avail_out)
{
return _BlocksOutputBuffer_Finish(buffer, (Py_ssize_t) avail_out);
}
static inline void
-Buffer_OnError(_BlocksOutputBuffer *buffer)
+OutputBuffer_OnError(_BlocksOutputBuffer *buffer)
{
_BlocksOutputBuffer_OnError(buffer);
}
@@ -177,7 +177,7 @@ compress(BZ2Compressor *c, char *data, size_t len, int action)
PyObject *result;
_BlocksOutputBuffer buffer = {.list = NULL};
- if (Buffer_InitAndGrow(&buffer, -1, &c->bzs.next_out, &c->bzs.avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, -1, &c->bzs.next_out, &c->bzs.avail_out) < 0) {
goto error;
}
c->bzs.next_in = data;
@@ -198,7 +198,7 @@ compress(BZ2Compressor *c, char *data, size_t len, int action)
break;
if (c->bzs.avail_out == 0) {
- if (Buffer_Grow(&buffer, &c->bzs.next_out, &c->bzs.avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &c->bzs.next_out, &c->bzs.avail_out) < 0) {
goto error;
}
}
@@ -215,13 +215,13 @@ compress(BZ2Compressor *c, char *data, size_t len, int action)
break;
}
- result = Buffer_Finish(&buffer, c->bzs.avail_out);
+ result = OutputBuffer_Finish(&buffer, c->bzs.avail_out);
if (result != NULL) {
return result;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
return NULL;
}
@@ -442,7 +442,7 @@ decompress_buf(BZ2Decompressor *d, Py_ssize_t max_length)
_BlocksOutputBuffer buffer = {.list = NULL};
bz_stream *bzs = &d->bzs;
- if (Buffer_InitAndGrow(&buffer, max_length, &bzs->next_out, &bzs->avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, max_length, &bzs->next_out, &bzs->avail_out) < 0) {
goto error;
}
@@ -469,21 +469,22 @@ decompress_buf(BZ2Decompressor *d, Py_ssize_t max_length)
} else if (d->bzs_avail_in_real == 0) {
break;
} else if (bzs->avail_out == 0) {
- if (Buffer_GetDataSize(&buffer, bzs->avail_out) == max_length)
+ if (OutputBuffer_GetDataSize(&buffer, bzs->avail_out) == max_length) {
break;
- if (Buffer_Grow(&buffer, &bzs->next_out, &bzs->avail_out) < 0) {
+ }
+ if (OutputBuffer_Grow(&buffer, &bzs->next_out, &bzs->avail_out) < 0) {
goto error;
}
}
}
- result = Buffer_Finish(&buffer, bzs->avail_out);
+ result = OutputBuffer_Finish(&buffer, bzs->avail_out);
if (result != NULL) {
return result;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
return NULL;
}
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index 0d6231953a3e7..2f80bf0496bb3 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -25,8 +25,8 @@
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
- uint8_t **next_out, size_t *avail_out)
+OutputBuffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
+ uint8_t **next_out, size_t *avail_out)
{
Py_ssize_t allocated;
@@ -39,8 +39,8 @@ Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_Grow(_BlocksOutputBuffer *buffer,
- uint8_t **next_out, size_t *avail_out)
+OutputBuffer_Grow(_BlocksOutputBuffer *buffer,
+ uint8_t **next_out, size_t *avail_out)
{
Py_ssize_t allocated;
@@ -51,19 +51,19 @@ Buffer_Grow(_BlocksOutputBuffer *buffer,
}
static inline Py_ssize_t
-Buffer_GetDataSize(_BlocksOutputBuffer *buffer, size_t avail_out)
+OutputBuffer_GetDataSize(_BlocksOutputBuffer *buffer, size_t avail_out)
{
return _BlocksOutputBuffer_GetDataSize(buffer, (Py_ssize_t) avail_out);
}
static inline PyObject *
-Buffer_Finish(_BlocksOutputBuffer *buffer, size_t avail_out)
+OutputBuffer_Finish(_BlocksOutputBuffer *buffer, size_t avail_out)
{
return _BlocksOutputBuffer_Finish(buffer, (Py_ssize_t) avail_out);
}
static inline void
-Buffer_OnError(_BlocksOutputBuffer *buffer)
+OutputBuffer_OnError(_BlocksOutputBuffer *buffer)
{
_BlocksOutputBuffer_OnError(buffer);
}
@@ -550,7 +550,7 @@ compress(Compressor *c, uint8_t *data, size_t len, lzma_action action)
_lzma_state *state = PyType_GetModuleState(Py_TYPE(c));
assert(state != NULL);
- if (Buffer_InitAndGrow(&buffer, -1, &c->lzs.next_out, &c->lzs.avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, -1, &c->lzs.next_out, &c->lzs.avail_out) < 0) {
goto error;
}
c->lzs.next_in = data;
@@ -573,19 +573,19 @@ compress(Compressor *c, uint8_t *data, size_t len, lzma_action action)
(action == LZMA_FINISH && lzret == LZMA_STREAM_END)) {
break;
} else if (c->lzs.avail_out == 0) {
- if (Buffer_Grow(&buffer, &c->lzs.next_out, &c->lzs.avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &c->lzs.next_out, &c->lzs.avail_out) < 0) {
goto error;
}
}
}
- result = Buffer_Finish(&buffer, c->lzs.avail_out);
+ result = OutputBuffer_Finish(&buffer, c->lzs.avail_out);
if (result != NULL) {
return result;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
return NULL;
}
@@ -934,7 +934,7 @@ decompress_buf(Decompressor *d, Py_ssize_t max_length)
_lzma_state *state = PyType_GetModuleState(Py_TYPE(d));
assert(state != NULL);
- if (Buffer_InitAndGrow(&buffer, max_length, &lzs->next_out, &lzs->avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, max_length, &lzs->next_out, &lzs->avail_out) < 0) {
goto error;
}
@@ -962,10 +962,10 @@ decompress_buf(Decompressor *d, Py_ssize_t max_length)
Maybe lzs's internal state still have a few bytes
can be output, grow the output buffer and continue
if max_lengh < 0. */
- if (Buffer_GetDataSize(&buffer, lzs->avail_out) == max_length) {
+ if (OutputBuffer_GetDataSize(&buffer, lzs->avail_out) == max_length) {
break;
}
- if (Buffer_Grow(&buffer, &lzs->next_out, &lzs->avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &lzs->next_out, &lzs->avail_out) < 0) {
goto error;
}
} else if (lzs->avail_in == 0) {
@@ -973,13 +973,13 @@ decompress_buf(Decompressor *d, Py_ssize_t max_length)
}
}
- result = Buffer_Finish(&buffer, lzs->avail_out);
+ result = OutputBuffer_Finish(&buffer, lzs->avail_out);
if (result != NULL) {
return result;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
return NULL;
}
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index fc63ca9445a8a..fe06094b0027a 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -19,8 +19,8 @@
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
- Bytef **next_out, uint32_t *avail_out)
+OutputBuffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
+ Bytef **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
@@ -33,15 +33,17 @@ Buffer_InitAndGrow(_BlocksOutputBuffer *buffer, Py_ssize_t max_length,
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_InitWithSize(_BlocksOutputBuffer *buffer, Py_ssize_t init_size,
- Bytef **next_out, uint32_t *avail_out)
+OutputBuffer_InitWithSize(_BlocksOutputBuffer *buffer, Py_ssize_t init_size,
+ Bytef **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
- if (init_size < 0 || (size_t)init_size > UINT32_MAX) {
- PyErr_SetString(PyExc_ValueError,
- "Initial buffer size should (0 <= size <= UINT32_MAX)");
- return -1;
+ if (init_size >= 0 && // ensure (size_t) cast is safe
+ (size_t)init_size > UINT32_MAX)
+ {
+ /* In 32-bit build, never reach this conditional branch.
+ The maximum block size accepted by zlib is UINT32_MAX. */
+ init_size = UINT32_MAX;
}
allocated = _BlocksOutputBuffer_InitWithSize(
@@ -53,8 +55,8 @@ Buffer_InitWithSize(_BlocksOutputBuffer *buffer, Py_ssize_t init_size,
/* On success, return value >= 0
On failure, return -1 */
static inline Py_ssize_t
-Buffer_Grow(_BlocksOutputBuffer *buffer,
- Bytef **next_out, uint32_t *avail_out)
+OutputBuffer_Grow(_BlocksOutputBuffer *buffer,
+ Bytef **next_out, uint32_t *avail_out)
{
Py_ssize_t allocated;
@@ -65,19 +67,19 @@ Buffer_Grow(_BlocksOutputBuffer *buffer,
}
static inline Py_ssize_t
-Buffer_GetDataSize(_BlocksOutputBuffer *buffer, uint32_t avail_out)
+OutputBuffer_GetDataSize(_BlocksOutputBuffer *buffer, uint32_t avail_out)
{
return _BlocksOutputBuffer_GetDataSize(buffer, (Py_ssize_t) avail_out);
}
static inline PyObject *
-Buffer_Finish(_BlocksOutputBuffer *buffer, uint32_t avail_out)
+OutputBuffer_Finish(_BlocksOutputBuffer *buffer, uint32_t avail_out)
{
return _BlocksOutputBuffer_Finish(buffer, (Py_ssize_t) avail_out);
}
static inline void
-Buffer_OnError(_BlocksOutputBuffer *buffer)
+OutputBuffer_OnError(_BlocksOutputBuffer *buffer)
{
_BlocksOutputBuffer_OnError(buffer);
}
@@ -248,7 +250,7 @@ zlib_compress_impl(PyObject *module, Py_buffer *data, int level)
Byte *ibuf = data->buf;
Py_ssize_t ibuflen = data->len;
- if (Buffer_InitAndGrow(&buffer, -1, &zst.next_out, &zst.avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, -1, &zst.next_out, &zst.avail_out) < 0) {
goto error;
}
@@ -280,7 +282,7 @@ zlib_compress_impl(PyObject *module, Py_buffer *data, int level)
do {
if (zst.avail_out == 0) {
- if (Buffer_Grow(&buffer, &zst.next_out, &zst.avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &zst.next_out, &zst.avail_out) < 0) {
deflateEnd(&zst);
goto error;
}
@@ -304,7 +306,7 @@ zlib_compress_impl(PyObject *module, Py_buffer *data, int level)
err = deflateEnd(&zst);
if (err == Z_OK) {
- RetVal = Buffer_Finish(&buffer, zst.avail_out);
+ RetVal = OutputBuffer_Finish(&buffer, zst.avail_out);
if (RetVal == NULL) {
goto error;
}
@@ -313,7 +315,7 @@ zlib_compress_impl(PyObject *module, Py_buffer *data, int level)
else
zlib_error(state, zst, err, "while finishing compression");
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
return NULL;
}
@@ -352,7 +354,7 @@ zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits,
bufsize = 1;
}
- if (Buffer_InitWithSize(&buffer, bufsize, &zst.next_out, &zst.avail_out) < 0) {
+ if (OutputBuffer_InitWithSize(&buffer, bufsize, &zst.next_out, &zst.avail_out) < 0) {
goto error;
}
@@ -385,7 +387,7 @@ zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits,
do {
if (zst.avail_out == 0) {
- if (Buffer_Grow(&buffer, &zst.next_out, &zst.avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &zst.next_out, &zst.avail_out) < 0) {
inflateEnd(&zst);
goto error;
}
@@ -428,13 +430,13 @@ zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits,
goto error;
}
- RetVal = Buffer_Finish(&buffer, zst.avail_out);
+ RetVal = OutputBuffer_Finish(&buffer, zst.avail_out);
if (RetVal != NULL) {
return RetVal;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
return NULL;
}
@@ -677,7 +679,7 @@ zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls,
self->zst.next_in = data->buf;
Py_ssize_t ibuflen = data->len;
- if (Buffer_InitAndGrow(&buffer, -1, &self->zst.next_out, &self->zst.avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, -1, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto error;
}
@@ -686,8 +688,9 @@ zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls,
do {
if (self->zst.avail_out == 0) {
- if (Buffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0)
+ if (OutputBuffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto error;
+ }
}
Py_BEGIN_ALLOW_THREADS
@@ -704,13 +707,13 @@ zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls,
} while (ibuflen != 0);
- RetVal = Buffer_Finish(&buffer, self->zst.avail_out);
+ RetVal = OutputBuffer_Finish(&buffer, self->zst.avail_out);
if (RetVal != NULL) {
goto success;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
RetVal = NULL;
success:
LEAVE_ZLIB(self);
@@ -799,15 +802,16 @@ zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls,
if (max_length < 0) {
PyErr_SetString(PyExc_ValueError, "max_length must be non-negative");
return NULL;
- } else if (max_length == 0)
+ } else if (max_length == 0) {
max_length = -1;
+ }
ENTER_ZLIB(self);
self->zst.next_in = data->buf;
ibuflen = data->len;
- if (Buffer_InitAndGrow(&buffer, max_length, &self->zst.next_out, &self->zst.avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, max_length, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto abort;
}
@@ -816,10 +820,10 @@ zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls,
do {
if (self->zst.avail_out == 0) {
- if (Buffer_GetDataSize(&buffer, self->zst.avail_out) == max_length) {
+ if (OutputBuffer_GetDataSize(&buffer, self->zst.avail_out) == max_length) {
goto save;
}
- if (Buffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto abort;
}
}
@@ -865,13 +869,13 @@ zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls,
goto abort;
}
- RetVal = Buffer_Finish(&buffer, self->zst.avail_out);
+ RetVal = OutputBuffer_Finish(&buffer, self->zst.avail_out);
if (RetVal != NULL) {
goto success;
}
abort:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
RetVal = NULL;
success:
LEAVE_ZLIB(self);
@@ -911,13 +915,13 @@ zlib_Compress_flush_impl(compobject *self, PyTypeObject *cls, int mode)
self->zst.avail_in = 0;
- if (Buffer_InitAndGrow(&buffer, -1, &self->zst.next_out, &self->zst.avail_out) < 0) {
+ if (OutputBuffer_InitAndGrow(&buffer, -1, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto error;
}
do {
if (self->zst.avail_out == 0) {
- if (Buffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0) {
+ if (OutputBuffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto error;
}
}
@@ -954,13 +958,13 @@ zlib_Compress_flush_impl(compobject *self, PyTypeObject *cls, int mode)
goto error;
}
- RetVal = Buffer_Finish(&buffer, self->zst.avail_out);
+ RetVal = OutputBuffer_Finish(&buffer, self->zst.avail_out);
if (RetVal != NULL) {
goto success;
}
error:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
RetVal = NULL;
success:
LEAVE_ZLIB(self);
@@ -1189,7 +1193,7 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
self->zst.next_in = data.buf;
ibuflen = data.len;
- if (Buffer_InitWithSize(&buffer, length, &self->zst.next_out, &self->zst.avail_out) < 0) {
+ if (OutputBuffer_InitWithSize(&buffer, length, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto abort;
}
@@ -1199,8 +1203,9 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
do {
if (self->zst.avail_out == 0) {
- if (Buffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0)
+ if (OutputBuffer_Grow(&buffer, &self->zst.next_out, &self->zst.avail_out) < 0) {
goto abort;
+ }
}
Py_BEGIN_ALLOW_THREADS
@@ -1243,13 +1248,13 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
}
}
- RetVal = Buffer_Finish(&buffer, self->zst.avail_out);
+ RetVal = OutputBuffer_Finish(&buffer, self->zst.avail_out);
if (RetVal != NULL) {
goto success;
}
abort:
- Buffer_OnError(&buffer);
+ OutputBuffer_OnError(&buffer);
RetVal = NULL;
success:
PyBuffer_Release(&data);
https://github.com/python/cpython/commit/e467ec476f624323b8638cf100d1bfbf1d…
commit: e467ec476f624323b8638cf100d1bfbf1d6a21c6
branch: master
author: Erlend Egeberg Aasland <erlend.aasland(a)innova.no>
committer: pablogsal <Pablogsal(a)gmail.com>
date: 2021-05-01T00:23:14+01:00
summary:
bpo-43995: Fix reference leak in test_grammar (GH-25764)
files:
M Lib/test/test_grammar.py
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 46f70e5d176fc..ebc9dde97e730 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -2,6 +2,7 @@
# This just tests whether the parser accepts them all.
from test.support import check_syntax_error
+from test.support import import_helper
from test.support.warnings_helper import check_syntax_warning
import inspect
import unittest
@@ -392,13 +393,13 @@ def test_var_annot_module_semantics(self):
def test_var_annot_in_module(self):
# check that functions fail the same way when executed
# outside of module where they were defined
- from test.ann_module3 import f_bad_ann, g_bad_ann, D_bad_ann
+ ann_module3 = import_helper.import_fresh_module("test.ann_module3")
with self.assertRaises(NameError):
- f_bad_ann()
+ ann_module3.f_bad_ann()
with self.assertRaises(NameError):
- g_bad_ann()
+ ann_module3.g_bad_ann()
with self.assertRaises(NameError):
- D_bad_ann(5)
+ ann_module3.D_bad_ann(5)
def test_var_annot_simple_exec(self):
gns = {}; lns= {}
https://github.com/python/cpython/commit/e726a902b7c73a7056b7421d801e47ffff…
commit: e726a902b7c73a7056b7421d801e47ffff255873
branch: master
author: Mohamed Moselhy <look4d(a)gmail.com>
committer: terryjreedy <tjreedy(a)udel.edu>
date: 2021-04-30T19:06:55-04:00
summary:
bpo-43971: Add spaces around annotated arg default '=' (GH-25702)
Result: "quantity_on_hand: int = 0".
files:
M Doc/library/dataclasses.rst
diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index e4d2b57fd4292..0e8db5003f5fe 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -33,7 +33,7 @@ using :pep:`526` type annotations. For example this code::
Will add, among other things, a :meth:`__init__` that looks like::
- def __init__(self, name: str, unit_price: float, quantity_on_hand: int=0):
+ def __init__(self, name: str, unit_price: float, quantity_on_hand: int = 0):
self.name = name
self.unit_price = unit_price
self.quantity_on_hand = quantity_on_hand
https://github.com/python/cpython/commit/e377ecf3b496c7719e6dffe3ebf3d0ef51…
commit: e377ecf3b496c7719e6dffe3ebf3d0ef512cfb5b
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: terryjreedy <tjreedy(a)udel.edu>
date: 2021-04-30T18:35:45-04:00
summary:
bpo-43935: Fix typo in Turtle.back() docstring (GH-25581)
'e ,' to 'e, '.
(cherry picked from commit 0048c60f01deec4435748e851f9ec21b504d2d2f)
Co-authored-by: Tarjei Bærland <tarjeibaerland(a)gmail.com>
files:
M Lib/turtle.py
diff --git a/Lib/turtle.py b/Lib/turtle.py
index 024fed858f683f..6e19032cce2a43 100644
--- a/Lib/turtle.py
+++ b/Lib/turtle.py
@@ -1645,7 +1645,7 @@ def back(self, distance):
Argument:
distance -- a number
- Move the turtle backward by distance ,opposite to the direction the
+ Move the turtle backward by distance, opposite to the direction the
turtle is headed. Do not change the turtle's heading.
Example (for a Turtle instance named turtle):
https://github.com/python/cpython/commit/e08c67372d62236409da296353827985a3…
commit: e08c67372d62236409da296353827985a3202e8a
branch: master
author: JT <jeffreytse.mail(a)gmail.com>
committer: terryjreedy <tjreedy(a)udel.edu>
date: 2021-04-30T18:35:07-04:00
summary:
bpo-43928: Fix 'succesfully' typo in document (GH-25569)
files:
M Doc/c-api/memory.rst
diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst
index 1cb0990f5d0115..efddc6f7be5e71 100644
--- a/Doc/c-api/memory.rst
+++ b/Doc/c-api/memory.rst
@@ -306,7 +306,7 @@ memory from the Python heap.
.. note::
There is no guarantee that the memory returned by these allocators can be
- succesfully casted to a Python object when intercepting the allocating
+ successfully casted to a Python object when intercepting the allocating
functions in this domain by the methods described in
the :ref:`Customize Memory Allocators <customize-memory-allocators>` section.
https://github.com/python/cpython/commit/a7f15ba5476051471638957b4d028097d0…
commit: a7f15ba5476051471638957b4d028097d080b290
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: miss-islington <31488909+miss-islington(a)users.noreply.github.com>
date: 2021-04-30T15:27:48-07:00
summary:
bpo-43935: Fix typo in Turtle.back() docstring (GH-25581)
'e ,' to 'e, '.
(cherry picked from commit 0048c60f01deec4435748e851f9ec21b504d2d2f)
Co-authored-by: Tarjei Bærland <tarjeibaerland(a)gmail.com>
files:
M Lib/turtle.py
diff --git a/Lib/turtle.py b/Lib/turtle.py
index 024fed858f683f..6e19032cce2a43 100644
--- a/Lib/turtle.py
+++ b/Lib/turtle.py
@@ -1645,7 +1645,7 @@ def back(self, distance):
Argument:
distance -- a number
- Move the turtle backward by distance ,opposite to the direction the
+ Move the turtle backward by distance, opposite to the direction the
turtle is headed. Do not change the turtle's heading.
Example (for a Turtle instance named turtle):
https://github.com/python/cpython/commit/0048c60f01deec4435748e851f9ec21b50…
commit: 0048c60f01deec4435748e851f9ec21b504d2d2f
branch: master
author: Tarjei Bærland <tarjeibaerland(a)gmail.com>
committer: terryjreedy <tjreedy(a)udel.edu>
date: 2021-04-30T18:05:45-04:00
summary:
bpo-43935: Fix typo in Turtle.back() docstring (GH-25581)
'e ,' to 'e, '.
files:
M Lib/turtle.py
diff --git a/Lib/turtle.py b/Lib/turtle.py
index 08c5b473df287..7d94720f8131d 100644
--- a/Lib/turtle.py
+++ b/Lib/turtle.py
@@ -1645,7 +1645,7 @@ def back(self, distance):
Argument:
distance -- a number
- Move the turtle backward by distance ,opposite to the direction the
+ Move the turtle backward by distance, opposite to the direction the
turtle is headed. Do not change the turtle's heading.
Example (for a Turtle instance named turtle):
https://github.com/python/cpython/commit/726c931b3896dc73fd156e2340b5ef0b8f…
commit: 726c931b3896dc73fd156e2340b5ef0b8f55cfb7
branch: master
author: Ammar Askar <ammar(a)ammaraskar.com>
committer: brettcannon <brett(a)python.org>
date: 2021-04-30T14:04:40-07:00
summary:
bpo-43888: Remove coverage builds from CI (GH-25679)
The coverage builds were consistently timing out in CI, suggesting that people were not reviewing the uploaded reports.
files:
D .github/codecov.yml
D .github/workflows/coverage.yml
M .travis.yml
M README.rst
diff --git a/.github/codecov.yml b/.github/codecov.yml
deleted file mode 100644
index ea504f48672eac..00000000000000
--- a/.github/codecov.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-codecov:
- strict_yaml_branch: master
- notify:
- require_ci_to_pass: true
-comment: off
-ignore:
- - "Doc/**/*"
- - "Misc/**/*"
- - "Mac/**/*"
- - "PC/**/*"
- - "PCbuild/**/*"
- - "Tools/**/*"
- - "Grammar/*"
-coverage:
- precision: 2
- range: 70...90
- round: down
- status:
- changes: off
- project: off
- patch: off
-parsers:
- gcov:
- branch_detection:
- conditional: true
- loop: true
- macro: false
- method: false
- javascript:
- enable_partials: false
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
deleted file mode 100644
index 1480a92b5c4400..00000000000000
--- a/.github/workflows/coverage.yml
+++ /dev/null
@@ -1,95 +0,0 @@
-name: Coverage
-
-on:
- push:
- branches:
- - master
- - 3.9
- - 3.8
- - 3.7
- paths-ignore:
- - 'Doc/**'
- - 'Misc/**'
- #pull_request:
- # branches:
- # - master
- # - 3.9
- # - 3.8
- # - 3.7
- # paths-ignore:
- # - 'Doc/**'
- # - 'Misc/**'
-
-jobs:
- coverage_ubuntu:
- name: 'Ubuntu (Coverage)'
- runs-on: ubuntu-latest
- env:
- OPENSSL_VER: 1.1.1k
- steps:
- - uses: actions/checkout@v2
- - name: Install Dependencies
- run: sudo ./.github/workflows/posix-deps-apt.sh
- - name: 'Restore OpenSSL build'
- id: cache-openssl
- uses: actions/cache(a)v2.1.4
- with:
- path: ./multissl/openssl/${{ env.OPENSSL_VER }}
- key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
- - name: Install OpenSSL
- if: steps.cache-openssl.outputs.cache-hit != 'true'
- run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $PWD/multissl --openssl $OPENSSL_VER --system Linux
- - name: Configure CPython
- run: ./configure --with-openssl=$PWD/multissl/openssl/$OPENSSL_VER
- - name: Build CPython
- run: make -j4
- - name: Display build info
- run: make pythoninfo
- - name: 'Coverage Preparation'
- run: |
- ./python -m venv .venv
- source ./.venv/bin/activate
- python -m pip install -U coverage
- python -m pip install -r Misc/requirements-test.txt
- python -m test.pythoninfo
- export PYTHONPATH=`find .venv -name fullcoverage`
- - name: 'Tests with coverage'
- timeout-minutes: 100 # 1h40m, ref https://bugs.python.org/issue43888
- run: >
- source ./.venv/bin/activate &&
- xvfb-run python -m coverage
- run --branch --pylib
- -m test
- --fail-env-changed
- -uall,-cpu
- -x test_multiprocessing_fork
- -x test_multiprocessing_forkserver
- -x test_multiprocessing_spawn
- -x test_concurrent_futures
- || true
- - name: 'Publish code coverage results'
- run: |
- export PYTHONPATH=
- source ./.venv/bin/activate
- bash <(curl -s https://codecov.io/bash ) -y .github/codecov.yml
- env:
- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
-
- c_coverage_ubuntu:
- name: 'Ubuntu (C Coverage)'
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Install Dependencies
- run: sudo ./.github/workflows/posix-deps-apt.sh
- - name: Configure CPython
- run: ./configure
- - name: 'Build CPython and measure coverage'
- run: xvfb-run make -j4 coverage-report
- - name: 'Publish code coverage results'
- if: always()
- run: |
- make pythoninfo
- bash <(curl -s https://codecov.io/bash ) -y .github/codecov.yml
- env:
- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.travis.yml b/.travis.yml
index fc063216914446..1112a0b266227b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -69,61 +69,6 @@ matrix:
- make -C Doc/ PYTHON=../python venv
script:
xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W -j4" doctest
- - name: "Test code coverage (Python)"
- os: linux
- language: c
- compiler: gcc
- env: OPTIONAL=true
- addons:
- apt:
- packages:
- - xvfb
- before_script:
- - |
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]
- then
- echo "Don't run Python coverage on pull requests."
- exit
- fi
- - ./configure
- - make -j4
- # Need a venv that can parse covered code.
- - ./python -m venv venv
- - ./venv/bin/python -m pip install -U coverage
- - ./venv/bin/python -m pip install -r Misc/requirements-test.txt
- - ./venv/bin/python -m test.pythoninfo
- - export PYTHONPATH=`find venv -name fullcoverage`
- script:
- # Skip tests that re-run the entire test suite.
- - xvfb-run ./venv/bin/python -m coverage run --branch --pylib -m test --fail-env-changed -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn -x test_concurrent_futures || true
- after_script: # Probably should be after_success once test suite updated to run under coverage.py.
- # Make the `coverage` command available to Codecov w/ a version of Python that can parse all source files.
- - export PYTHONPATH=
- - source ./venv/bin/activate
- - bash <(curl -s https://codecov.io/bash ) -y .github/codecov.yml
- - name: "Test code coverage (C)"
- os: linux
- language: c
- compiler: gcc
- env: OPTIONAL=true
- addons:
- apt:
- packages:
- - lcov
- - xvfb
- before_script:
- - |
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]
- then
- echo "Don't run C coverage on pull requests."
- exit
- fi
- - ./configure
- script:
- - xvfb-run make -j4 coverage-report
- after_script: # Probably should be after_success once test suite updated to run under coverage.py.
- - make pythoninfo
- - bash <(curl -s https://codecov.io/bash ) -y .github/codecov.yml
before_install:
diff --git a/README.rst b/README.rst
index 02a34d28aa489a..18d6e6a96f937e 100644
--- a/README.rst
+++ b/README.rst
@@ -13,10 +13,6 @@ This is Python version 3.10.0 alpha 7
:alt: CPython build status on Azure DevOps
:target: https://dev.azure.com/python/cpython/_build/latest?definitionId=4&branchNam…
-.. image:: https://codecov.io/gh/python/cpython/branch/master/graph/badge.svg
- :alt: CPython code coverage on Codecov
- :target: https://codecov.io/gh/python/cpython
-
.. image:: https://img.shields.io/badge/discourse-join_chat-brightgreen.svg
:alt: Python Discourse chat
:target: https://discuss.python.org/
https://github.com/python/cpython/commit/6143fcdf8bfe54c24e3081bcee423f4d51…
commit: 6143fcdf8bfe54c24e3081bcee423f4d51f35c4e
branch: master
author: Dong-hee Na <donghee.na(a)python.org>
committer: miss-islington <31488909+miss-islington(a)users.noreply.github.com>
date: 2021-04-30T12:01:55-07:00
summary:
bpo-43979: Remove unnecessary operation from urllib.parse.parse_qsl (GH-25756)
Automerge-Triggered-By: GH:gpshead
files:
A Misc/NEWS.d/next/Library/2021-05-01-01-36-51.bpo-43979.43oJ9L.rst
M Lib/urllib/parse.py
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index c11c695a741c8a..4249163f0edde7 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -752,9 +752,8 @@ def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
if max_num_fields < num_fields:
raise ValueError('Max number of fields exceeded')
- pairs = [s1 for s1 in qs.split(separator)]
r = []
- for name_value in pairs:
+ for name_value in qs.split(separator):
if not name_value and not strict_parsing:
continue
nv = name_value.split('=', 1)
diff --git a/Misc/NEWS.d/next/Library/2021-05-01-01-36-51.bpo-43979.43oJ9L.rst b/Misc/NEWS.d/next/Library/2021-05-01-01-36-51.bpo-43979.43oJ9L.rst
new file mode 100644
index 00000000000000..d5d1caa3e56827
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-05-01-01-36-51.bpo-43979.43oJ9L.rst
@@ -0,0 +1,2 @@
+Removed an unnecessary list comprehension before looping from
+:func:`urllib.parse.parse_qsl`. Patch by Christoph Zwerschke and Dong-hee Na.
https://github.com/python/cpython/commit/6689e45dfee75d756c540ff0946ebf0ae8…
commit: 6689e45dfee75d756c540ff0946ebf0ae8847f43
branch: master
author: Pablo Galindo <Pablogsal(a)gmail.com>
committer: pablogsal <Pablogsal(a)gmail.com>
date: 2021-04-30T19:34:29+01:00
summary:
bpo-43981: Fix reference leaks in test_squeezer (GH-25758)
files:
A Misc/NEWS.d/next/IDLE/2021-04-30-17-59-56.bpo-43981.3EFl1H.rst
M Lib/idlelib/idle_test/test_squeezer.py
diff --git a/Lib/idlelib/idle_test/test_squeezer.py b/Lib/idlelib/idle_test/test_squeezer.py
index eaf81a5fc1a053..86c5d41b629719 100644
--- a/Lib/idlelib/idle_test/test_squeezer.py
+++ b/Lib/idlelib/idle_test/test_squeezer.py
@@ -311,6 +311,7 @@ def make_mock_squeezer(self):
squeezer = Mock()
squeezer.editwin.text = Text(root)
squeezer.editwin.per = Percolator(squeezer.editwin.text)
+ self.addCleanup(squeezer.editwin.per.close)
# Set default values for the configuration settings.
squeezer.auto_squeeze_min_lines = 50
diff --git a/Misc/NEWS.d/next/IDLE/2021-04-30-17-59-56.bpo-43981.3EFl1H.rst b/Misc/NEWS.d/next/IDLE/2021-04-30-17-59-56.bpo-43981.3EFl1H.rst
new file mode 100644
index 00000000000000..10eb8b01d13a48
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2021-04-30-17-59-56.bpo-43981.3EFl1H.rst
@@ -0,0 +1 @@
+Fix reference leak in test_squeezer. Patch by Pablo Galindo
\ No newline at end of file