Commit Graph

5923 Commits

Author SHA1 Message Date
Miss Islington (bot) fbf7aac36b
bpo-18533: Avoid RecursionError from repr() of recursive dictview (GH-4823)
dictview_repr(): Use a Py_ReprEnter() / Py_ReprLeave() pair to check
for recursion, and produce "..." if so.

test_recursive_repr(): Check for the string rather than a
RecursionError.  (Test cannot be any tighter as contents are
implementation-dependent.)

test_deeply_nested_repr(): Add new test, replacing the original
test_recursive_repr().  It checks that a RecursionError is raised in
the case of a non-recursive but deeply nested structure.  (Very
similar to what test_repr_deep() in test/test_dict.py does for a
normal dict.)

OrderedDictTests: Add new test case, to test behavior on OrderedDict
instances containing their own values() or items().
(cherry picked from commit d7773d92bd)
2018-02-26 06:42:00 -08:00
INADA Naoki 4731634241
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
(cherry picked from commit d019bc8319)
2018-02-13 22:15:24 +09:00
Miss Islington (bot) 310b424c47
bpo-32827: Fix usage of _PyUnicodeWriter_Prepare() in decoding errors handler. (GH-5636)
(cherry picked from commit b7e2d67f7c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-02-13 01:32:46 -08:00
Terry Jan Reedy c90a5dec03
[3.6] bpo-32746: Fix multiple typos (GH-5144) (GH-5522)
Fix typos found by codespell in docs, docstrings, and comments.
Fixes for the following files were in post-3.6 code and not backported:
Lib/ctypes/_aix.py (new), Lib/test/test_concurrent_futures.py,
Modules/_asynciomodule.c, Modules/_pickle.c, Objects/obmalloc.c.

(cherry picked from commit c3d9508ff2)
2018-02-03 21:00:24 -05:00
Miss Islington (bot) 688b6dec4e bpo-32137: The repr of deeply nested dict now raises a RecursionError (GH-4570) (GH-4689)
instead of crashing due to a stack overflow.

This perhaps will fix similar problems in other extension types.
(cherry picked from commit 1fb72d2ad2)
2018-02-01 13:57:28 +02:00
Xiang Zhang ea94fce696
[3.6] bpo-32583: Fix possible crashing in builtin Unicode decoders (GH-5325) (#5459)
When using customized decode error handlers, it is possible for builtin decoders
to write out-of-bounds and then crash..
(cherry picked from commit 2c7fd46e11)
2018-01-31 21:34:17 +08:00
Nick Coghlan 05f91a42cd
[3.6] Revert "bpo-32690: Preserve order of locals() (GH-5379) (#5390)"
This reverts commit 9105879bfd
in order to keep the behaviour of locals() consistent between
3.6.4 and 3.6.5+.
2018-01-30 15:27:41 +10:00
Miss Islington (bot) 9105879bfd bpo-32690: Preserve order of locals() (GH-5379) (#5390)
(cherry picked from commit a4d0001256)
2018-01-28 10:13:17 -08:00
Miss Islington (bot) b3b4b81d01 bpo-32685: Improve suggestion for print statement (GH-5380)
Better account for single-line compound statements and
semi-colon separated statements when suggesting
Py3 replacements for Py2 print statements.

Initial patch by Nitish Chandra.
(cherry picked from commit 43c0f1ac5e)
2018-01-28 21:31:48 +10:00
Miss Islington (bot) d7274c6638 Fix wrong assert in unicodeobject (GH-5340)
(cherry picked from commit 7cc95f5069)
2018-01-28 02:41:24 +09:00
Miss Islington (bot) 4002d5dbf4 [3.6] bpo-32028: Fix suggestions for indented print statements (GH-5249)
The suggested replacement for print statements previously failed to account
for leading whitespace and hence could end up including unwanted text in
the proposed call to the print builtin.

Patch by Sanyam Khurana.
(cherry picked from commit d57f26c753)
2018-01-20 13:56:31 +10:00
Miss Islington (bot) 051650ab8d Removed unnecesssary bit inversion which doesn't improve dispersion statistics (GH-5235) (#5236)
(cherry picked from commit fa78806041)
2018-01-18 14:27:22 -08:00
Miss Islington (bot) e7dbd06583 bpo-26163: Frozenset hash improvement (GH-5194) (#5198)
(cherry picked from commit b44c5169f6)
2018-01-16 02:27:15 -08:00
Victor Stinner b92c159efa
[3.6] bpo-32555: Fix locale encodings (#5193)
On FreeBSD and Solaris, os.strerror() now always decode the byte
string from the current locale encoding, rather than using
ASCII/surrogateescape in some cases.

Changes:

* Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() which has an
  additional current_locale parameter.
* PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and
* PyUnicode_EncodeLocale() now always use the current locale
* encoding, instead of using Py_DecodeLocale()/Py_EncodeLocale().
* Document encoding in Py_DecodeLocale() and Py_EncodeLocale()
  documentations.
* Add USE_FORCE_ASCII define to not define
  decode_ascii_surrogateescape() on Android.
2018-01-15 23:43:24 +01:00
Miss Islington (bot) 78e43a59ac Fix outdated comment in typeobject.c (GH-5090)
The comment was added in 3abca127fe.
In d78448e912, it was changed to
use PyArg_ParseTuple instead.

(cherry picked from commit 78e24d4415)
2018-01-04 14:06:47 +03:00
Miss Islington (bot) 30a6bc8429 bpo-31619: Fixed integer overflow in converting huge strings to int. (GH-3884) (#4690)
(cherry picked from commit 29ba688034)
2017-12-03 23:27:21 +02:00
Nick Coghlan c8f32aae0a
[3.6] bpo-32176: Set CO_NOFREE in the code object constructor (GH-4684)
Previously, CO_NOFREE was set in the compiler, which meant
it could end up being set incorrectly when code objects
were created directly. Setting it in the constructor based
on freevars and cellvars ensures it is always accurate,
regardless of how the code object is defined.

(cherry picked from commit 078f1814f1)
2017-12-03 23:32:54 +10:00
Victor Stinner dedcbee04c
[3.6] bpo-30923, bpo-31279: Fix GCC warnings (#4620)
* bpo-30923: Silence fall-through warnings in libexpat build. (#3205)

(cherry picked from commit 9e1e6f528f)

* bpo-31279: Silence -Wstringop-overflow warning. (#3207)

(cherry picked from commit dce6502059)
2017-11-30 00:00:35 +01:00
Miss Islington (bot) 58cbae2293 bpo-16055: Fixes incorrect error text for int('1', base=1000) (GH-4376) (#4389)
(cherry picked from commit 28b624825e)
2017-11-14 01:35:13 -08:00
Miss Islington (bot) ece5659565 bpo-31626: Fixed a bug in debug memory allocator. (GH-3844) (#4191)
Removed a code that incorrectly detected in-place resizing in realloc()
 and wrote to freed memory.
(cherry picked from commit b484d5606c)
2017-10-31 15:58:33 +02:00
Serhiy Storchaka 9ea5a3a45b
[3.6] bpo-20047: Make bytearray methods partition() and rpartition() rejecting (GH-4158) (#4162)
separators that are not bytes-like objects..
(cherry picked from commit a2314283ff)
2017-10-29 12:24:45 +02:00
xdegaye 4b27d51222 [3.6] bpo-30697: Fix PyErr_NormalizeException() when no memory (GH-2327). (#4135)
(cherry picked from commit 56d1f5ca32)
2017-10-26 17:48:48 +02:00
Miss Islington (bot) 1e78ed6825 bpo-31825: Fixed OverflowError in the 'unicode-escape' codec (GH-4058) (#4059)
and in codecs.escape_decode() when decode an escaped non-ascii byte.
(cherry picked from commit 56cb465cc9)
2017-10-20 17:41:29 +03:00
Miss Islington (bot) cae6e4775b [3.6] bpo-31655: Validate keyword names in SimpleNamespace constructor. (GH-3909) (#3920)
(cherry picked from commit 79ba471488)
2017-10-07 23:52:57 +03:00
Miss Islington (bot) b5a630f3dd [3.6] bpo-31619: Fixed a ValueError when convert a string with large number of underscores (GH-3827) (#3863)
to integer with binary base.
(cherry picked from commit 85c0b8941f)
2017-10-03 15:38:46 +03:00
Serhiy Storchaka f0db2dfda7 [3.6] bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (GH-3620). (#3773)
(cherry picked from commit 6db7033192)
2017-09-27 07:33:00 +03:00
Serhiy Storchaka d6a356209a [3.6] bpo-31579: Fixed a possible leak in enumerate() with large indices. (GH-3753). (#3760)
(cherry picked from commit 0e950dd22b)
2017-09-26 09:11:34 +03:00
Victor Stinner c0e77364ca [3.6] bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0 (#3518)
* bpo-30923: Disable warning that has been part of -Wextra since gcc-7.0. (#3142)

(cherry picked from commit d73a960c57)

* bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. (#3157)

(cherry picked from commit f432a3234f)

* bpo-31275: Small refactoring to silence a fall-through warning. (#3206)

(cherry picked from commit 138753c1b9)
2017-09-12 16:09:44 -07:00
Benjamin Peterson cb356c2ecc [3.6] bpo-31373: remove overly strict float range checks (GH-3486) (#3495)
This undoes a853a8ba78 except for the pytime.c
parts. We want to continue to allow IEEE 754 doubles larger than FLT_MAX to be
rounded into finite floats. Tests were added to very this behavior.
(cherry picked from commit 2bb69a5b4e)
2017-09-11 23:08:49 -07:00
Henk-Jaap Wagenaar 2a0f7c34c3 Backport docstring improvements to OrderedDict. (GH-3470) 2017-09-10 18:11:18 -07:00
Serhiy Storchaka ddb536ba7b [3.6] bpo-31393: Fix the use of PyUnicode_READY(). (GH-3451). (#3453)
(cherry picked from commit e3b2b4b8d9)
2017-09-08 10:43:54 +03:00
Miss Islington (bot) b03623227e [3.6] fixes bpo-31373: fix undefined floating-point demotions (GH-3396) (#3424)
(cherry picked from commit a853a8ba78)
2017-09-07 11:35:03 -07:00
Mariatta 3b9d4444fe [3.6] bpo-30662: fixed OrderedDict.__init__ docstring re PEP 468 (GH-2179) (GH-3370)
* fixed OrderedDict.__init__ docstring re PEP 468

* tightened comment and mirrored to C impl

* added space after period per marco-buttu

* preserved substituted for stable

* drop references to Python 3.6 and PEP 468
(cherry picked from commit faa57cbe70)
2017-09-05 18:13:07 -07:00
INADA Naoki 2eea952b1b bpo-31095: fix potential crash during GC (GH-3195)
(cherry picked from commit a6296d34a4)
2017-09-04 12:31:09 +09:00
Martijn Pieters 680f04a926 bpo-31161: only check for parens error for SyntaxError (#3083)
Subclasses such as IndentError and TabError should not have this message
applied.
2017-08-22 13:11:09 -07:00
Nick Coghlan 1a05e87ec7 [3.6] bpo-31232: Backport custom print rshift message (GH-3155)
bpo-30721 added a "Did you mean ...?" suggestion to rshift
TypeError messages that triggers when the LHS is a Python
C function called "print".

Since this custom error message is expected to be triggered
primarily by attempts to use Python 2 print redirection syntax
in Python 3, and is incredibly unlikely to be encountered
otherwise, it is also being backported to the next 3.6
maintenance release.

Initial patch by Sanyam Khurana.
2017-08-19 16:59:38 +10:00
Serhiy Storchaka f08b2be441 [3.6] bpo-30978: str.format_map() now passes key lookup exceptions through. (GH-2790) (#2992)
Previously any exception was replaced with a KeyError exception.
(cherry picked from commit 5075416)
2017-08-03 12:14:07 +03:00
Serhiy Storchaka 82a9075600 [3.6] bpo-22207: Add checks for possible integer overflows in unicodeobject.c. (GH-2623) (#2658)
Based on patch by Victor Stinner.
(cherry picked from commit 64e461b)
2017-07-11 07:27:56 +03:00
Nick Coghlan bfdc6fdc0e [3.6] bpo-30597: Show expected input in custom 'print' error message. (GH-2531)
(cherry picked from commit 3a7f03584a)
2017-07-03 17:49:50 +10:00
Serhiy Storchaka 0834905d9b [3.6] bpo-13617: Reject embedded null characters in wchar* strings. (GH-2302) (#2462)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters..
(cherry picked from commit f7eae0adfc)
2017-06-28 09:27:35 +03:00
Victor Stinner 26daad4ee1 bpo-30704, bpo-30604: Fix memleak in code_dealloc() (#2455) (#2456)
Free also co_extra->ce_extras, not only co_extra.
(cherry picked from commit 23e7944eba)
2017-06-28 02:28:51 +02:00
Serhiy Storchaka 0edffa3073 [3.6] bpo-30708: Check for null characters in PyUnicode_AsWideCharString(). (GH-2285) (#2443)
Raise a ValueError if the second argument is NULL and the wchar_t\*
string contains null characters..
(cherry picked from commit e613e6add5)
2017-06-27 21:08:58 +03:00
Serhiy Storchaka e7135751b8 [3.6] bpo-30730: Prevent environment variables injection in subprocess on Windows. (GH-2325) (#2360)
Prevent passing other invalid environment variables and command arguments..
(cherry picked from commit d174d24a5d)
2017-06-23 20:17:38 +03:00
Dino Viehland 2997fec01e [3.6] bpo-30604: Move co_extra_freefuncs to interpreter state to avoid crashes in threads (#2015)
* Move co_extra_freefuncs to interpreter state to avoid crashes in
multi-threaded scenarios involving deletion of code objects

* Don't require that extra be zero initialized

* Build test list instead of defining empty test class

* Ensure extra is always assigned on success

* Keep the old fields in the thread state object, just don't use them
Add new linked list of code extra objects on a per-interpreter basis
  so that interpreter state size isn't changed

* Rename __PyCodeExtraState_Get and add comment about it going away in 3.7
Fix sort order of import's in test_code.py

* Remove an extraneous space

* Remove docstrings for comments

* Touch up formatting

* Fix casing of coextra local

* Fix casing of another variable

* Prefix PyCodeExtraState with __ to match C API for getting it

* Update NEWS file for bpo-30604
2017-06-12 21:46:35 -04:00
Victor Stinner f0ff849adc bpo-30524: Fix _PyStack_UnpackDict() (#1886)
* bpo-29259: Remove unused func parameter of _PyStack_UnpackDict()
* bpo-29286: Change _PyStack_UnpackDict() prototype to be able to
  notify of failure when args is NULL. _PyStack_UnpackDict() now
  returns -1 on error.
2017-06-09 13:24:53 +02:00
Serhiy Storchaka 564398af6c [3.6] bpo-27945: Fixed various segfaults with dict. (GH-1657) (#1677)
Based on patches by Duane Griffin and Tim Mitchell.
(cherry picked from commit 753bca3934)
2017-05-20 13:06:26 +03:00
Serhiy Storchaka 193f7e094f [3.6] bpo-25794: Fix `type.__setattr__()` for non-interned attribute names. (GH-1652) (#1673)
Based on patch by Eryk Sun.
(cherry picked from commit d896985bb2)
2017-05-20 10:23:31 +03:00
Xiang Zhang 98b49a00d4 bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480) (#1529) 2017-05-10 19:00:15 +08:00
Serhiy Storchaka 7a113a0cbf bpo-29802: Fix the cleaning up issue in PyUnicode_FSDecoder(). (#1217) 2017-04-20 22:55:06 +03:00
Dong-hee Na df5df13fdc [3.6] bpo-12414: Update code_sizeof() to take in account co_extra memory. (#1168) (#1198) 2017-04-20 11:26:25 +03:00