Commit Graph

6263 Commits

Author SHA1 Message Date
Benjamin Peterson 4d5d219a7a
[3.7] Fix misleading mentions of tp_size in comments. (GH-9136)
Many type object initializations labeled a field "tp_size" in the
comment, but the name of that field is tp_basicsize..
(cherry picked from commit 0e0bc4e221)

Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
2018-09-10 10:22:55 -07:00
Miss Islington (bot) f862f3abae
bpo-25750: fix refcounts in type_getattro() (GH-6118)
When calling tp_descr_get(self, obj, type), make sure that
we own a strong reference to "self".
(cherry picked from commit 8f735485ac)

Co-authored-by: jdemeyer <jdemeyer@cage.ugent.be>
2018-09-07 00:50:35 -07:00
Miss Islington (bot) d6725fcdd5
closes bpo-34504: Remove the useless NULL check in PySequence_Check(). (GH-8935)
Reported by Svace static analyzer.
(cherry picked from commit b57b4ac042)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-25 20:03:48 -04:00
Miss Islington (bot) 15dadacabf
closes bpo-34501: PyType_FromSpecWithBases: Check spec->name before dereferencing it. (GH-8930)
Reported by Svace static analyzer.
(cherry picked from commit 5f79b50763)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-25 15:11:29 -04:00
Miss Islington (bot) 46af206ea4
closes bpo-34493: Objects/genobject.c: Add missing NULL check to compute_cr_origin() (GH-8911)
(cherry picked from commit 8fdd331bbf)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-25 03:36:34 -04:00
Miss Islington (bot) d9e1abf8d3
closes bpo-34468: Objects/rangeobject.c: Fix an always-false condition in range_repr() (GH-8880)
Also, propagate the error from PyNumber_AsSsize_t() because we don't care
only about OverflowError which is not reported if the second argument is NULL.

Reported by Svace static analyzer.
(cherry picked from commit 7ecae3ca0b)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-24 01:34:06 -04:00
Miss Islington (bot) 609062a23f
closes bpo-34477: Objects/typeobject.c: Add missing NULL check to type_init() (GH-8876)
Reported by Svace static analyzer.
(cherry picked from commit f6247aac08)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-24 00:38:16 -04:00
Miss Islington (bot) 042082692b
bpo-34436: Fix check that disables overallocation for the last fmt specifier (GH-8826)
Reported by Svace static analyzer.
(cherry picked from commit ccd9975267)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-23 04:03:02 -04:00
Miss Islington (bot) 1e596d3a20
bpo-34435: Add missing NULL check to unicode_encode_ucs1(). (GH-8823)
Reported by Svace static analyzer.
(cherry picked from commit 74a307d48e)

Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
2018-08-19 16:17:53 -04:00
Miss Islington (bot) 5594f1dfbe
bpo-24618: Add a check in the code constructor. (GH-8283)
Check that the size of the varnames tuple is enough at least for all arguments.
(cherry picked from commit bd47384e07)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-07-16 00:09:44 -07:00
Miss Islington (bot) c721472fb8
bpo-34087: Fix buffer overflow in int(s) and similar functions (GH-8274)
`_PyUnicode_TransformDecimalAndSpaceToASCII()` missed trailing NUL char.
It caused buffer overflow in `_Py_string_to_number_with_underscores()`.

This bug is introduced in 9b6c60cb.
(cherry picked from commit 16dfca4d82)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-07-13 20:58:12 -07:00
Miss Islington (bot) 127bd9bfd5
bpo-34042: Fix dict.copy() to maintain correct total refcount (GH-8119)
(cherry picked from commit 0b75228700)

Co-authored-by: Yury Selivanov <yury@magic.io>
2018-07-06 09:40:17 -07:00
Miss Islington (bot) 4e9d9b314d
fix two typos in Objects/odictobject.c comments (GH-8040)
(cherry picked from commit 6f19fc6d56)

Co-authored-by: Robert Krzyzanowski <technoguyrob@gmail.com>
2018-07-06 05:08:51 -07:00
Miss Islington (bot) 4705ea38c9 update to Unicode 11.0.0 (closes bpo-33778) (GH-7439) (GH-7470)
Also, standardize indentation of generated tables.
(cherry picked from commit 7c69c1c0fb)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-06-07 03:36:22 -04:00
Miss Islington (bot) a0ff51964f
Fix typo in __mul__ and __rmul__ docstring (GH-6674)
(cherry picked from commit 0904f766e1)

Co-authored-by: Grant Jenks <grant.jenks@gmail.com>
2018-05-08 22:49:47 -07:00
Miss Islington (bot) 6a56790e0b
bpo-33391: Fix refleak in set_symmetric_difference (GH-6670)
(cherry picked from commit 491bbedc20)

Co-authored-by: lekma <lekmalek@gmail.com>
2018-05-02 02:50:48 -07:00
Miss Islington (bot) 32955299b4
Spelling fixes to docs, docstrings, and comments (GH-6374)
(cherry picked from commit 61f82e0e33)

Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
2018-04-20 14:00:41 -07:00
Miss Islington (bot) 392520bd78 bpo-33312: Fix clang ubsan out of bounds warnings in dict. (GH-6537) (GH-6543)
Fix clang ubsan (undefined behavior sanitizer) warnings in dictobject.c by
adjusting how the internal struct _dictkeysobject shared keys structure is
declared.

This remains ABI compatible.  We get rid of the union at the end of the
struct being used for conveinence to avoid typecasting in favor of char[]
variable length array at the end of a struct. This is known to clang to be
used for variable sized objects and will not cause an undefined behavior
problem.  Similarly, char arrays do not have strict aliasing undefined
behavior when cast.

PEP-007 does not currently list variable length arrays (VLAs) as allowed
in our subset of C99.  If this turns out to be a problem, the fix to this is
to change the char `dk_indices[]` into `dk_indices[1]` and restore the
three size computation subtractions this change removes:
  `- Py_MEMBER_SIZE(PyDictKeysObject, dk_indices)`

If this works as is I'll make a separate PR to update PEP-007.
(cherry picked from commit 397f1b28c4)
2018-04-20 10:06:21 -07:00
Miss Islington (bot) 902bb62d5a
bpo-33205: dict: Change GROWTH_RATE to `used*3` (GH-6350)
(cherry picked from commit 5fbc511f56)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-04-17 10:17:19 -07:00
Serhiy Storchaka b0f387d7ca
[3.7] bpo-33031: Remove dead code in C implementation of OrderedDict. (GH-6120) (GH-6433)
This code doesn't have effect on the final result, but causes
GCC 8 warnings and can have an undefined behavior.
(cherry picked from commit 827d49f3cf)
2018-04-09 21:46:41 +03:00
Miss Islington (bot) de755129a7
bpo-33199: Initialize ma_version_tag in PyDict_Copy (GH-6341)
(cherry picked from commit d1c82c5cc7)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-04-02 20:00:26 -07:00
Miss Islington (bot) a6c3299605
Fix typo and edit for clarity in the docstrings of sys.float_info. (GH-2251)
(cherry picked from commit 0301c9bdd1)

Co-authored-by: Stefano Taschini <taschini@users.noreply.github.com>
2018-03-26 03:58:10 -07:00
Miss Islington (bot) 136905fffd
bpo-32374: m_traverse may be called with m_state=NULL (GH-5140)
Multi-phase initialized modules allow m_traverse to be called while the
module is still being initialized, so module authors may need to account
for that.
(cherry picked from commit c2b0b12d1a)

Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com>
2018-03-16 23:03:56 -07:00
xdegaye e32bbaf376 [3.7] bpo-17288: Prevent jumps from 'return' and 'exception' trace events. (GH-5928) 2018-03-13 10:52:35 +02:00
Serhiy Storchaka 04aadf23ea
[3.7] bpo-33026: Fix jumping out of "with" block by setting f_lineno. (GH-6026). (#6074)
(cherry picked from commit 26c9f565d0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-03-11 09:30:13 +02:00
Miss Islington (bot) bc2e110469
closes bpo-32898: Fix debug build crash with COUNT_ALLOCS (GH-5800)
(cherry picked from commit 745dc65b17)

Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com>
2018-02-21 21:44:08 -08:00
Miss Islington (bot) ef20abed7f
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
(cherry picked from commit d019bc8319)

Co-authored-by: Oren Milman <orenmn@gmail.com>
2018-02-13 03:32:18 -08:00
Miss Islington (bot) 09819ef05a bpo-32827: Fix usage of _PyUnicodeWriter_Prepare() in decoding errors handler. (GH-5636) (GH-5650)
(cherry picked from commit b7e2d67f7c)


Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-02-13 09:15:57 +02:00
Miss Islington (bot) e86db34dd3 [3.7] bpo-32746: Fix multiple typos (GH-5144) (GH-5520)
Fix typos found by codespell in docs, docstrings, and comments.
(cherry picked from commit c3d9508ff2)

Co-authored-by: Leo Arias <leo.arias@canonical.com>
2018-02-03 20:41:43 -05:00
Xiang Zhang 86fdad093b bpo-32583: Fix possible crashing in builtin Unicode decoders (#5325)
When using customized decode error handlers, it is possible for builtin decoders
to write out-of-bounds and then crash.
2018-01-31 17:02:12 -05:00
Yury Selivanov 2a2270db9b
bpo-32703: Fix coroutine resource warning in case where there's an error (GH-5410)
The commit removes one unnecessary "if" clause in genobject.c.  That "if" clause was masking un-awaited coroutines warnings just to make writing unittests more convenient.
2018-01-29 14:31:47 -05:00
Victor Stinner 8017b804a0
bpo-28685: Fix compiler warning (GH-5423) 2018-01-29 13:47:06 +01:00
embg 1e34da49ef bpo-28685: Optimize sorted() list.sort() with type-specialized comparisons (#582) 2018-01-28 19:03:23 -08:00
Raymond Hettinger a4d0001256
bpo-32690: Preserve order of locals() (#5379) 2018-01-28 09:40:24 -08:00
Nitish Chandra 43c0f1ac5e bpo-32685: Improve suggestion for print statement (GH-5375)
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.
2018-01-28 20:56:02 +10:00
INADA Naoki bea57060c8
bpo-32677: Optimize str.isascii() (GH-5356) 2018-01-28 09:59:12 +09:00
INADA Naoki 7cc95f5069
Fix wrong assert in unicodeobject (GH-5340) 2018-01-28 02:07:09 +09:00
INADA Naoki a49ac99029
bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342) 2018-01-27 14:06:21 +09:00
Yury Selivanov 43c47fe096
bpo-32670: Enforce PEP 479. (#5327) 2018-01-26 15:24:24 -05:00
bennorth d7773d92bd bpo-18533: Avoid RecursionError from repr() of recursive dictview (#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().
2018-01-26 07:46:01 -08:00
INADA Naoki e76daebc0c
bpo-32571: Fix reading uninitialized memory (GH-5332)
Reported by Coverity Scan.
2018-01-26 16:22:51 +09:00
Serhiy Storchaka f320be77ff bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code (GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
2018-01-25 17:49:40 +09:00
Yury Selivanov f23746a934
bpo-32436: Implement PEP 567 (#5027) 2018-01-22 19:11:18 -05:00
Yury Selivanov b0a7a037b8
bpo-31179: Make dict.copy() up to 5.5 times faster. (#3067) 2018-01-22 11:54:41 -05:00
Nathaniel J. Smith fc2f407829 bpo-32591: Add native coroutine origin tracking (#5250)
* Add coro.cr_origin and sys.set_coroutine_origin_tracking_depth
* Use coroutine origin information in the unawaited coroutine warning
* Stop using set_coroutine_wrapper in asyncio debug mode
* In BaseEventLoop.set_debug, enable debugging in the correct thread
2018-01-21 09:44:07 -05:00
Sanyam Khurana d57f26c753 bpo-32028: Fix suggestions for indented print statements (GH-4688)
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.
2018-01-20 13:12:22 +10:00
Raymond Hettinger fa78806041
Removed unnecesssary bit inversion which doesn't improve dispersion statistics (#5235) 2018-01-18 13:23:27 -08:00
INADA Naoki 378edee0a3
bpo-32544: Speed up hasattr() and getattr() (GH-5173)
AttributeError was raised always when attribute is not found.
This commit skip raising AttributeError when `tp_getattro` is `PyObject_GenericGetAttr`.
It makes hasattr() and getattr() about 4x faster when attribute is not found.
2018-01-16 20:52:41 +09:00
Raymond Hettinger b44c5169f6
bpo-26163: Frozenset hash improvement (#5194) 2018-01-16 01:30:26 -08:00
Victor Stinner 7ed7aead95
bpo-29240: Fix locale encodings in UTF-8 Mode (#5170)
Modify locale.localeconv(), time.tzname, os.strerror() and other
functions to ignore the UTF-8 Mode: always use the current locale
encoding.

Changes:

* Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx(). On decoding or
  encoding error, they return the position of the error and an error
  message which are used to raise Unicode errors in
  PyUnicode_DecodeLocale() and PyUnicode_EncodeLocale().
* Replace _Py_DecodeCurrentLocale() with _Py_DecodeLocaleEx().
* PyUnicode_DecodeLocale() now uses _Py_DecodeLocaleEx() for all
  cases, especially for the strict error handler.
* Add _Py_DecodeUTF8Ex(): return more information on decoding error
  and supports the strict error handler.
* Rename _Py_EncodeUTF8_surrogateescape() to _Py_EncodeUTF8Ex().
* Replace _Py_EncodeCurrentLocale() with _Py_EncodeLocaleEx().
* Ignore the UTF-8 mode to encode/decode localeconv(), strerror()
  and time zone name.
* Remove PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize()
  and PyUnicode_EncodeLocale() now ignore the UTF-8 mode: always use
  the "current" locale.
* Remove _PyUnicode_DecodeCurrentLocale(),
  _PyUnicode_DecodeCurrentLocaleAndSize() and
  _PyUnicode_EncodeCurrentLocale().
2018-01-15 10:45:49 +01:00