Commit Graph

6326 Commits

Author SHA1 Message Date
Miss Islington (bot) 9cbf43adfe
Fix typo in dict object comment (GH-15814)
(cherry picked from commit 359143c686)

Co-authored-by: dalgarno <32097481+dalgarno@users.noreply.github.com>
2019-09-10 03:15:43 -07:00
Miss Islington (bot) 021e5db20b
bpo-36946:Fix possible signed integer overflow when handling slices. (GH-15639)
This is a complement to PR 13375.
(cherry picked from commit 3c87a667bb)

Co-authored-by: HongWeipeng <hongweichen8888@sina.com>
2019-09-08 03:36:38 -07:00
Miss Islington (bot) 735a960ac9
bpo-36311: Fixes decoding multibyte characters around chunk boundaries and improves decoding performance (GH-15083)
(cherry picked from commit 7ebdda0dbe)

Co-authored-by: Steve Dower <steve.dower@python.org>
2019-08-21 16:55:57 -07:00
Victor Stinner c9a484a1e7
bpo-37732: Fix GCC warning in _PyObject_Malloc() (GH-15333) (GH-15342) (GH-15343)
pymalloc_alloc() now returns directly the pointer, return NULL on
memory allocation error.

allocate_from_new_pool() already uses NULL as marker for "allocation
failed".

(cherry picked from commit 18f8dcfa10)
(cherry picked from commit 30e5aff5fb)
2019-08-20 15:29:08 +01:00
Miss Islington (bot) 15b6d0a712
bpo-37681: no_sanitize_thread support from GCC 5.1 (GH-15096)
Fix the following warning with GCC 4.8.5:
Objects/obmalloc.c: warning: ‘no_sanitize_thread’ attribute directive ignored
(cherry picked from commit 7e479c8221)

Co-authored-by: Hai Shi <shihai1992@gmail.com>
2019-08-14 03:16:54 -07:00
Miss Islington (bot) 7675bca4b5
bpo-37417: Fix error handling in bytearray.extend. (GH-14407)
(cherry picked from commit 2a7d596f27)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2019-06-26 12:23:19 -07:00
Miss Islington (bot) c755ca89c7 [3.7] bpo-24214: Fixed the UTF-8 and UTF-16 incremental decoders. (GH-14304) (GH-14369)
* bpo-24214: Fixed the UTF-8 and UTF-16 incremental decoders. (GH-14304)

* The UTF-8 incremental decoders fails now fast if encounter
  a sequence that can't be handled by the error handler.
* The UTF-16 incremental decoders with the surrogatepass error
  handler decodes now a lone low surrogate with final=False.
(cherry picked from commit 894263ba80)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-06-25 12:29:18 +02:00
Raymond Hettinger 1b615b2f03
[3.7] bpo-37219: Remove erroneous optimization for differencing an empty set (GH-13965) (GH-13968) 2019-06-11 02:01:06 -07:00
Zackery Spytz e36ed475ea [3.7] bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860) (GH-13896)
(cherry picked from commit dc2476500d)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-06-07 17:41:10 +02:00
Petr Viktorin 3708316afa [3.7] Fix a possible crash due to PyType_FromSpecWithBases() (GH-10304) (GH-13495)
If the PyObject_MALLOC() call failed in PyType_FromSpecWithBases(),
PyObject_Free() would be called on a static string in type_dealloc().
(cherry picked from commit 0613c1e481)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-05-28 23:35:33 -04:00
Miss Islington (bot) e7ddf586ae
bpo-26423: Fix possible overflow in wrap_lenfunc() (GH-13606)
Fix possible overflow in wrap_lenfunc() when
sizeof(long) < sizeof(Py_ssize_t) (e.g., 64-bit Windows).
(cherry picked from commit 05f16416d9)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-05-28 06:17:43 -07:00
Miss Islington (bot) bfd0b77201
[3.7] bpo-28866: No type cache for types with specialized mro, invalidation is hard. (GH-13157) (GH-13589)
* No type cache for types with specialized mro, invalidation is hard.

* FIX: Don't disable method cache custom types that do not implement mro().

* fixing implem.

* Avoid storing error flags, also decref.

* news entry

* Clear as soon as we're getting an error.

* FIX: Reference leak.
(cherry picked from commit 180dc1b0f4)


Co-authored-by: Julien Palard <julien@palard.fr>


https://bugs.python.org/issue28866
2019-05-26 15:14:23 -07:00
Miss Islington (bot) 1b85f4ec45
bpo-27987: pymalloc: align by 16bytes on 64bit platform (GH-12850)
(cherry picked from commit f0be4bbb9b)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2019-05-25 10:18:34 -07:00
Miss Islington (bot) 367fe5757a
bpo-35091: Objects/listobject.c: Replace overflow checks in gallop fu… (GH-10202)
…nctions with asserts

The actual overflow can never happen because of the following:
* The size of a list can't be greater than PY_SSIZE_T_MAX / sizeof(PyObject*).
* The size of a pointer on all supported plaftorms is at least 4 bytes.
* ofs is positive and less than the list size at the beginning of each iteration.

https://bugs.python.org/issue35091
(cherry picked from commit 6bc5917903)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2019-05-22 17:18:55 -07:00
Jeroen Demeyer d092caf096 bpo-36907: fix refcount bug in _PyStack_UnpackDict() (GH-13381) (GH-13493) 2019-05-22 14:52:13 +02:00
Miss Islington (bot) 64b0bdba7e
closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
(cherry picked from commit 53d378c812)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-05-19 17:54:08 -07:00
Stéphane Wirtel 9050aaf6ee
[3.7] Fix typo in _PyMethodDef_RawFastCallKeywords error message (GH-13343) (GH-13385)
(cherry picked from commit a8b46944d7)

Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
2019-05-17 13:34:47 +02:00
Miss Islington (bot) f02d1a43c6
bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)
The final addition (cur += step) may overflow, so use size_t for "cur".
"cur" is always positive (even for negative steps), so it is safe to use
size_t here.

Co-Authored-By: Martin Panter <vadmium+py@gmail.com>
(cherry picked from commit 14514d9084)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-05-17 00:33:10 -07:00
Miss Islington (bot) 128e2262a8
bpo:34848 : Correct an incorrect docstring for range().index method (GH-9877)
(cherry picked from commit 22c526394b)

Co-authored-by: Srinivas Reddy Thatiparthy (శ్రీనివాస్  రెడ్డి తాటిపర్తి) <thatiparthysreenivas@gmail.com>
2019-05-03 05:39:17 -07:00
Miss Islington (bot) 896c6357f3
bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12993)
https://bugs.python.org/issue36745
(cherry picked from commit e0dcb85b7d)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-04-28 06:17:40 -07:00
Victor Stinner 9e23f0a27c
[3.7] bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770) (GH-12788)
* bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770)

Replace _PyMem_IsFreed() function with _PyMem_IsPtrFreed() inline
function. The function is now way more efficient, it became a simple
comparison on integers, rather than a short loop. It detects also
uninitialized bytes and "forbidden bytes" filled by debug hooks
on memory allocators.

Add unit tests on _PyObject_IsFreed().

(cherry picked from commit 2b00db6855)

* bpo-36389: Change PyMem_SetupDebugHooks() constants (GH-12782)

Modify CLEANBYTE, DEADDYTE and FORBIDDENBYTE constants: use 0xCD,
0xDD and 0xFD, rather than 0xCB, 0xBB and 0xFB, to use the same byte
patterns than Windows CRT debug malloc() and free().

(cherry picked from commit 4c409beb4c)
2019-04-11 22:30:31 +02:00
Miss Islington (bot) bd48280cb6 bpo-24214: Fixed the UTF-8 incremental decoder. (GH-12603) (GH-12627)
The bug occurred when the encoded surrogate character is passed
to the incremental decoder in two chunks.
(cherry picked from commit 7a465cb5ee)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-03-30 15:52:41 +02:00
Miss Islington (bot) 03440850e7
bpo-36433: fix confusing error messages in classmethoddescr_call (GH-12556)
https://bugs.python.org/issue36433
(cherry picked from commit 871309c775)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2019-03-26 02:47:08 -07:00
Miss Islington (bot) 9dbb09fc27 bpo-36218: Fix handling of heterogeneous values in list.sort (GH-12209) GH-12532)
(cherry picked from commit dd5417afcf)

Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
2019-03-25 00:47:55 -07:00
Miss Islington (bot) 74829b7323
bpo-36312: Fix decoders for some code pages. (GH-12369)
(cherry picked from commit c1e2c288f4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-03-20 21:31:57 -07:00
Victor Stinner ea3592d7ef
bpo-36365: Fix compiler warning in structseq.c (GH-12451) 2019-03-20 00:32:11 +01:00
Serhiy Storchaka 783bed4c8d
[3.7] bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264). (GH-12322)
(cherry picked from commit d53fe5f407)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-03-14 10:47:27 +02:00
Miss Islington (bot) e4be2057d4
bpo-36251: Fix format strings used in match_repr() and stdprinter_repr(). (GH-12252)
(cherry picked from commit 8b91edadc0)

Co-authored-by: sth <sth.dev@tejp.de>
2019-03-10 03:52:44 -07:00
Miss Islington (bot) 0e73ea26a5
bpo-33989: Ensure that ms.key_compare is always initialized in list_sort_impl(). (GH-8710)
(cherry picked from commit ebc793d6ac)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-02-21 00:05:22 -08:00
Miss Islington (bot) 64ca728223
bpo-31506: Clarify error messages for object.__new__ and object.__init__ (GH-11641)
`object.__new__` and `object.__init__` do take one argument each,
they just don't take extra user supplied arguments.

Patch by Sanyam Khurana.
(cherry picked from commit 5105483acb)

Co-authored-by: Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com>
2019-02-19 05:47:13 -08:00
Miss Islington (bot) a7f929db60
bpo-35992: Use PySequence_GetItem only if sq_item is not NULL (GH-11857)
Not using `__class_getitem__()` fallback if there is a non-subcriptable metaclass was caused by a certain asymmetry between how `PySequenceMethods` and `PyMappingMethods` are used in `PyObject_GetItem`. This PR removes this asymmetry. No tests failed, so I assume it was not intentional.
(cherry picked from commit ac28147e78)

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
2019-02-17 15:33:04 -08:00
Miss Islington (bot) a78251e2d6
bpo-35961: Fix a crash in slice_richcompare() (GH-11830)
Fix a crash in slice_richcompare(): use strong references rather than
stolen references for the two temporary internal tuples.

The crash (or assertion error) occurred if a garbage collection
occurred during slice_richcompare(), especially while calling
PyObject_RichCompare(t1, t2, op).
(cherry picked from commit dcb68f47f7)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-02-13 03:49:34 -08:00
Miss Islington (bot) cbc7c2c791
bpo-35552: Fix reading past the end in PyUnicode_FromFormat() and PyBytes_FromFormat(). (GH-11276)
Format characters "%s" and "%V" in PyUnicode_FromFormat() and "%s" in PyBytes_FromFormat()
no longer read memory past the limit if precision is specified.
(cherry picked from commit d586ccb04f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-01-12 00:52:55 -08:00
Miss Islington (bot) d39c192559
bpo-33817: Fix _PyBytes_Resize() for empty bytes object. (GH-11516)
Add also tests for PyUnicode_FromFormat() and PyBytes_FromFormat()
with empty result.
(cherry picked from commit 44cc4822bb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-01-11 23:40:09 -08:00
Miss Islington (bot) 9a413faa87
bpo-35560: Remove assertion from format(float, "n") (GH-11288)
Fix an assertion error in format() in debug build for floating point
formatting with "n" format, zero padding and small width. Release build is
not impacted. Patch by Karthikeyan Singaravelan.
(cherry picked from commit 3f7983a25a)

Co-authored-by: Xtreak <tir.karthi@gmail.com>
2019-01-07 07:26:20 -08:00
Miss Islington (bot) a5955b0895
closes bpo-35623: Fix integer overflow when sorting large lists (GH-11380)
There is already a `Py_ssize_t i` defined at function scope that is used
for similar loops. By removing the local `int i` declaration that `i` is
used, which has the appropriate type.
(cherry picked from commit f8b534477a)

Co-authored-by: sth <sth.dev@tejp.de>
2019-01-01 18:25:23 -08:00
Miss Islington (bot) cb272843f2
bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
(cherry picked from commit 842acaab13)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-12-17 07:10:20 -08:00
Serhiy Storchaka 3cae16d2e9
bpo-35444: Fix error handling when fail to look up builtin "getattr". (GH-11047) (GH-11107)
(cherry picked from commit bb86bf4c4e)
2018-12-11 10:51:27 +02:00
Miss Islington (bot) 62674f3a36
bpo-35454: Fix miscellaneous minor issues in error handling. (GH-11077)
* bpo-35454: Fix miscellaneous minor issues in error handling.

* Fix a null pointer dereference.
(cherry picked from commit 8905fcc85a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-12-10 23:05:13 -08:00
Zackery Spytz 602d307ac5 bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) (GH-11020)
(cherry picked from commit 4c49da0cb7)
2018-12-07 14:17:43 +02:00
Miss Islington (bot) bdeb56cd21
bpo-35372: Fix the code page decoder for input > 2 GiB. (GH-10848)
(cherry picked from commit 4013c17911)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-12-03 01:09:11 -08:00
Miss Islington (bot) 1659c08d5d
bpo-33012: Fix more invalid function cast warnings with gcc 8. (GH-10751)
Fix warnings with gcc 8 for wrapperfunc <-> wrapperfunc_kwds casts.
(cherry picked from commit 1c607155c9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-11-29 06:27:49 -08:00
Victor Stinner 85ab974f78
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759) (GH-10761)
Fix memory leak in PyUnicode_EncodeLocale() and
PyUnicode_EncodeFSDefault() on error handling.

Fix unicode_encode_locale() error handling.

(cherry picked from commit bde9d6bbb4)
2018-11-28 12:42:40 +01:00
Serhiy Storchaka ad8ac54aa3
bpo-33012: Fix signatures of METH_NOARGS functions. (GH-10736) (GH-10748)
(cherry picked from commit 81524022d0)
2018-11-27 20:27:47 +02:00
Miss Islington (bot) 5ceb7018dc
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
(cherry picked from commit d4f9cf5545)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-11-27 09:58:07 -08:00
Victor Stinner 7f9fb0f345
bpo-33954: Rewrite FILL() macro of unicodeobject.c (GH-10738)
Copy code from master: add assertions on start and value, replace 'i'
iterator with 'end' pointer for the loop stop condition.

_PyUnicode_FastFill(): fix type of 'data', it must not be constant,
since data is modified by FILL().
2018-11-27 12:42:04 +01:00
Victor Stinner 6f5fa1b4be
bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623) (GH-10718)
Fix str.format(), float.__format__() and complex.__format__() methods
for non-ASCII decimal point when using the "n" formatter.

Rewrite _PyUnicode_InsertThousandsGrouping(): it now requires
a _PyUnicodeWriter object for the buffer and a Python str object
for digits.

(cherry picked from commit 59423e3ddd)
2018-11-26 14:17:01 +01:00
Victor Stinner 95036ea25d
[3.7] bpo-9263: _PyObject_Dump() detects freed memory (GH-10061) (GH-10662)
* bpo-9263: _PyObject_Dump() detects freed memory (GH-10061)

_PyObject_Dump() now uses an heuristic to check if the object memory
has been freed: log "<freed object>" in that case.

The heuristic rely on the debug hooks on Python memory allocators
which fills the memory with DEADBYTE (0xDB) when memory is
deallocated. Use PYTHONMALLOC=debug to always enable these debug
hooks.

(cherry picked from commit 82af0b63b0)

* bpo-9263: Fix _PyObject_Dump() for freed object (#10661)

If _PyObject_Dump() detects that the object is freed, don't try to
dump it (exit immediately).

Enhance also _PyObject_IsFreed(): it now detects if the pointer
itself looks like freed memory.

(cherry picked from commit 2cf5d32fd9)
2018-11-22 17:15:37 +01:00
Miss Islington (bot) ae02a929dd
bpo-35269: Fix a possible segfault involving a newly-created coroutine (GH-10585)
coro->cr_origin wasn't initialized if compute_cr_origin() failed in
PyCoro_New(), which would cause a crash during the coroutine's
deallocation.

https://bugs.python.org/issue35269
(cherry picked from commit 062a57bf4b)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-11-18 08:58:20 -08:00
Miss Islington (bot) 9fbcb1402e
[3.7] bpo-35214: Fix OOB memory access in unicode escape parser (GH-10506) (GH-10522)
Discovered using clang's MemorySanitizer when it ran python3's
test_fstring test_misformed_unicode_character_name.

An msan build will fail by simply executing: ./python -c 'u"\N"'
(cherry picked from commit 746b2d35ea)


Co-authored-by: Gregory P. Smith <greg@krypto.org>


https://bugs.python.org/issue35214
2018-11-13 16:39:36 -08:00