Commit Graph

10749 Commits

Author SHA1 Message Date
Miss Islington (bot) 740a7cde9c
bpo-36908: 'This module is always available' isn't helpful. (GH-13297)
Makes the documentation of math and cmath module
more helpful for the beginners.
(cherry picked from commit 6faad355db)

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2019-05-17 14:08:21 -07: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
Steve Dower aa73841a8f
bpo-35926: Add support for OpenSSL 1.1.1b on Windows (GH-11779) 2019-05-16 09:41:36 -07:00
Miss Islington (bot) 5f5b187bfa
bpo-36734: Fix compilation of faulthandler.c on HP-UX (GH-12970)
Initialize "stack_t current_stack" to zero using memset().
(cherry picked from commit b84cb70880)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-04-30 14:30:44 -07:00
Miss Islington (bot) f5972cc0c9 bpo-2091: Fix typo in exception message (GH-12987)
(cherry picked from commit 21a9ba1992)

Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
2019-04-27 23:39:06 +03:00
Miss Islington (bot) c0f6f53703
bpo-18372: Add missing PyObject_GC_Track() calls in the pickle module (GH-8505)
(cherry picked from commit 359bd4f61b)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-04-23 05:18:15 -07:00
Victor Stinner 8a9a6b443c
[3.7] bpo-9566: Fix compiler warnings on Windows (GH-12920)
* bpo-9566: Fix compiler warnings in gcmodule.c (GH-11010)

Change PyDTrace_GC_DONE() argument type from int to Py_ssize_t.

(cherry picked from commit edad38e3e0)

* bpo-30465: Fix C downcast warning on Windows in ast.c (#6593)

ast.c: fstring_fix_node_location() downcasts a pointer difference to
a C int. Replace int with Py_ssize_t to fix the compiler warning.

(cherry picked from commit fb7e7992be)

* bpo-9566: Fix compiler warnings in peephole.c (GH-10652)

(cherry picked from commit 028f0ef4f3)

* bpo-27645, sqlite: Fix integer overflow on sleep (#6594)

Use the _PyTime_t type and round away from zero (ROUND_UP,
_PyTime_ROUND_TIMEOUT) the sleep duration, when converting a Python
object to seconds and then to milliseconds. Raise an OverflowError in
case of overflow.

Previously the (int)double conversion rounded towards zero
(ROUND_DOWN).

(cherry picked from commit ca405017d5)
2019-04-23 10:26:11 +02:00
Marcin Niemira 1100ae8f3f bpo-36523: Add docstring to io.IOBase.writelines (GH-12683)
(cherry picked from commit ab86521a9d)
2019-04-22 21:08:24 +09:00
Miss Islington (bot) 8b30ee8435 bpo-36650: Fix handling of empty keyword args in C version of lru_cache. (GH-12881) (GH-12888)
(cherry picked from commit 14adbd4598)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
2019-04-20 07:50:32 -10: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
Pablo Galindo 513d142993
[3.7] bpo-36440: include node names in ParserError messages, instead of numeric IDs (GH-12565) (GH-12671)
The error messages in the parser module are referring to numeric IDs for the nodes. To improve readability, use the node names when reporting errors..
(cherry picked from commit cb0748d393)

Co-authored-by: tyomitch <tyomitch@gmail.com>
2019-04-03 14:34:59 -04:00
Miss Islington (bot) 9c08eeb30c
bpo-36504: Fix signed integer overflow in _ctypes.c's PyCArrayType_new(). (GH-12660)
(cherry picked from commit 487b73ab39)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-04-03 10:55:26 -07:00
Inada Naoki 8384670615
bpo-20844: open script file with "rb" mode (GH-12616)
(cherry picked from commit 10654c19b5)
2019-04-01 21:02:51 +09:00
Miss Islington (bot) 5e233951d9 bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106) (GH-12642)
(cherry picked from commit 5f2c50810a)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-03-31 20:15:11 +03:00
Miss Islington (bot) e9868c5416
bpo-35941: Fix ssl certificate enumeration for windows (GH-12486)
Add a function to collect certificates from several certificate stores into one certificate collection store that is then enumerated. This ensures we load as many certificates as we can access.
(cherry picked from commit d93fbbf88e)

Co-authored-by: kctherookie <48805853+kctherookie@users.noreply.github.com>
2019-03-28 11:56:50 -07:00
Miss Islington (bot) 20fde53a25
bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)
Handle memory allocation failure.
(cherry picked from commit 414b1cde93)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-03-26 08:39:03 -07:00
Miss Islington (bot) e0fe25be1e
bpo-36430: Fix a possible reference leak in itertools.count(). (GH-12551)
(cherry picked from commit 0523c39e77)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-03-25 23:26:42 -07:00
Miss Islington (bot) fa27870992
bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). (GH-12530)
Set type_attr to NULL after the assignment to stgdict->proto (like
what is done with stgdict after the Py_SETREF() call) so that it is
not decrefed twice on error.
(cherry picked from commit 5e333784f0)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-03-25 01:34:26 -07:00
Miss Islington (bot) 00eb97b4a7 bpo-36256: Fix bug in parsermodule when parsing if statements (GH-12488)
bpo-36256: Fix bug in parsermodule when parsing if statements

In the parser module, when validating nodes before starting the parsing with to create a ST in "parser_newstobject" there is a problem that appears when two arcs in the same DFA state has transitions with labels with the same type. For example, the DFA for if_stmt has a state with
two labels with the same type: "elif" and "else" (type NAME). The algorithm tries one by one the arcs until the label that starts the arc transition has a label with the same type of the current child label we are trying to accept. In this case, the arc for "elif" comes before the arc for "else"and passes this test (because the current child label is "else" and has the same type as "elif"). This lead to expecting a namedexpr_test (305) instead of a colon (11). The solution is to compare also the string representation (in case there is one) of the labels to see if the transition that we have is the correct one.
(cherry picked from commit 9a0000d15d)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-03-21 23:56:20 +00:00
Victor Stinner ef10f886ae
Fix compiler warning in call_readline() (GH-10820) (GH-12452)
Replace strncpy() with memcpy() in call_readline() to fix the
following warning, the NUL byte is written manually just after:

Modules/readline.c: In function ‘call_readline’:
Modules/readline.c:1303:9: warning: ‘strncpy’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
         strncpy(p, q, n);
         ^~~~~~~~~~~~~~~~
Modules/readline.c:1279:9: note: length computed here
     n = strlen(p);
         ^~~~~~~~~

(cherry picked from commit 1600f60414)
2019-03-20 01:00:41 +01:00
Victor Stinner f7959a9fe7
bpo-36236: Handle removed cwd at Python init (GH-12450)
At Python initialization, the current directory is no longer
prepended to sys.path if it has been removed.
2019-03-20 00:30:45 +01:00
Victor Stinner 935250d6f3
bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12436)
Ensure that _PyRuntime_Finalize() is always call. This change fix a
few memory leaks when running "python3 -V".
2019-03-19 15:08:17 +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) 42c649347a
bpo-36209: Fix typo on hashlib error message (GH-12194)
(cherry picked from commit b71e28ea91)

Co-authored-by: Emmanuel Arias <emmanuelarias30@gmail.com>
2019-03-06 06:54:54 -08:00
Miss Islington (bot) a59d33a1b0
bpo-36179: Fix ref leaks in _hashopenssl (GH-12158)
Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in
out-of-memory cases. Thanks to Charalampos Stratakis.

Signed-off-by: Christian Heimes <christian@python.org>

https://bugs.python.org/issue36179
(cherry picked from commit b7bc283ab6)

Co-authored-by: Christian Heimes <christian@python.org>
2019-03-04 08:17:30 -08:00
Miss Islington (bot) e5897b67ba bpo-28441: Ensure `.exe` suffix in `sys.executable` on MinGW and Cygwin (GH-4348)
This is needed to even the run the test suite on buildbots for affected platforms; e.g.:

```
./python.exe  ./Tools/scripts/run_tests.py -j 1 -u all -W --slowest --fail-env-changed --timeout=11700 -j2
/home/embray/src/python/test-worker/3.x.test-worker/build/python -u -W default -bb -E -W error::BytesWarning -m test -r -w -j 1 -u all -W --slowest --fail-env-changed --timeout=11700 -j2
Traceback (most recent call last):
  File "./Tools/scripts/run_tests.py", line 56, in <module>
    main(sys.argv[1:])
  File "./Tools/scripts/run_tests.py", line 52, in main
    os.execv(sys.executable, args)
PermissionError: [Errno 13] Permission denied
make: *** [Makefile:1073: buildbottest] Error 1
```

(cherry picked from commit 7a7693e9cb)

Co-authored-by: E. M. Bray <erik.m.bray@gmail.com>
2019-02-27 18:24:34 +09:00
Miss Islington (bot) 4e6646fef5
bpo-36106: Resolve sinpi name clash with libm (IEEE-754 violation). (GH-12027)
The standard math library (libm) may follow IEEE-754 recommendation to
include an implementation of sinPi(), i.e. sinPi(x):=sin(pi*x).
And this triggers a name clash, found by FreeBSD developer
Steve Kargl, who worken on putting sinpi into libm used on FreeBSD
(it has to be named "sinpi", not "sinPi", cf. e.g.
https://en.cppreference.com/w/c/experimental/fpext4).
(cherry picked from commit f57cd8288d)

Co-authored-by: Dima Pasechnik <dimpase@gmail.com>
2019-02-25 23:10:54 -08:00
Miss Islington (bot) 0b3019a02e
bpo-24643: Fix "GH-define timezone _timezone" clashes on Windows (GH-12019)
(cherry picked from commit 6673decfa0)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-02-25 16:15:04 -08:00
Miss Islington (bot) 8efa32888b
fix _abc.c compile error on Cygwin (GH-8445)
(cherry picked from commit abe5922743)

Co-authored-by: E. M. Bray <erik.m.bray@gmail.com>
2019-02-23 17:53:28 -08:00
Miss Islington (bot) 3129432845 bpo-34572: change _pickle unpickling to use import rather than retrieving from sys.modules (GH-9047) (GH-11921)
Fix C implementation of pickle.loads to use importlib's locking mechanisms, and thereby avoid using partially-loaded modules.
(cherry picked from commit 4371c0a9c0)

Co-authored-by: tjb900 <ozburgess@gmail.com>
2019-02-18 15:52:32 +00:00
Miss Islington (bot) 0e379d43ac
bpo-34294: re module, fix wrong capturing groups in rare cases. (GH-11546)
Need to reset capturing groups between two SRE(match) callings in loops, this fixes wrong capturing groups in rare cases.

Also add a missing index in re.rst.
(cherry picked from commit 4a7f44a2ed)

Co-authored-by: animalize <animalize@users.noreply.github.com>
2019-02-18 05:48:23 -08:00
Miss Islington (bot) a01065a358
bpo-35942: Improve the error message if __fspath__ returns invalid types in path_converter (GH-11831)
The error message emitted when returning invalid types from __fspath__ in interfaces that allow passing PathLike objects has been improved and now it does explain the origin of the error.
(cherry picked from commit 09fbcd6085)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-02-18 03:05:52 -08:00
Miss Islington (bot) e20893596f
closes bpo-35991: Fix a potential double free in Modules/_randommodule.c. (GH-11849)
(cherry picked from commit bb3c05d7ef)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-02-14 00:02:12 -08:00
Benjamin Peterson 00cc0fe177
[3.7] Remove stray quote in os.replace docstring. (GH-11835)
(cherry picked from commit 73d600239b)

Co-authored-by: Anthony Sottile <asottile@umich.edu>
2019-02-12 20:36:09 -08:00
Miss Islington (bot) 7c7839329c lru_cache: Add more comments. Fix comment typos. Clarify a comment. (GH-11795) (GH-11798) 2019-02-08 19:33:06 -08:00
Miss Islington (bot) 63a69ef4a2
bpo-29734: nt._getfinalpathname handle leak (GH-740)
Make sure that failure paths call CloseHandle outside of the function that failed
(cherry picked from commit b82bfac436)

Co-authored-by: Mark Becwar <mark@thebecwar.com>
2019-02-02 13:29:07 -08:00
Miss Islington (bot) 533a9b459b Consistently move the misses update to just before the user function call (GH-11715) (GH-11716) 2019-01-31 15:35:00 -08:00
Miss Islington (bot) 10354cbb50
bpo-35847: RISC-V needs CTYPES_PASS_BY_REF_HACK (GH-11694)
This fixes the ctypes.test.test_structures.StructureTestCase test.

https://bugs.python.org/issue35847
(cherry picked from commit 742d768656)

Co-authored-by: Andreas Schwab <schwab@linux-m68k.org>
2019-01-29 13:11:36 -08:00
Miss Islington (bot) b2b023c657 bpo-35780: Fix errors in lru_cache() C code (GH-11623) (GH-11682) 2019-01-26 03:23:40 -05:00
Miss Islington (bot) f71e7433eb
bpo-35720: Fixing a memory leak in pymain_parse_cmdline_impl() (GH-11528)
When the loop in the pymain_read_conf function in this same file
calls pymain_init_cmdline_argv() a 2nd time, the pymain->command
buffer of wchar_t is overriden and the previously allocated memory
is never freed.
(cherry picked from commit 35ca1820e1)

Co-authored-by: Lucas Cimon <lucas.cimon@gmail.com>
2019-01-22 08:42:13 -08:00
Miss Islington (bot) be5de958e9
bpo-35746: Fix segfault in ssl's cert parser (GH-11569)
Fix a NULL pointer deref in ssl module. The cert parser did not handle CRL
distribution points with empty DP or URI correctly. A malicious or buggy
certificate can result into segfault.

Signed-off-by: Christian Heimes <christian@python.org>

https://bugs.python.org/issue35746
(cherry picked from commit a37f52436f)

Co-authored-by: Christian Heimes <christian@python.org>
2019-01-15 15:03:36 -08:00
Miss Islington (bot) 26122de1a8
bpo-35066: _dateime.datetime.strftime copies trailing '%' (GH-10692)
Previously, calling the strftime() method on a datetime object with a
trailing '%' in the format string would result in an exception. However,
this only occured when the datetime C module was being used; the python
implementation did not match this behavior. Datetime is now PEP-399
compliant, and will not throw an exception on a trailing '%'.
(cherry picked from commit 454b3d4ea2)

Co-authored-by: MichaelSaah <mike.saah@gmail.com>
2019-01-14 02:41:33 -08:00
Miss Islington (bot) 059997d78e
bpo-32710: Fix _overlapped.Overlapped memory leaks (GH-11489)
Fix memory leaks in asyncio ProactorEventLoop on overlapped operation
failures.

Changes:

* Implement the tp_traverse slot in the _overlapped.Overlapped type
  to help to break reference cycles and identify referrers in the
  garbage collector.
* Always clear overlapped on failure: not only set type to
  TYPE_NOT_STARTED, but release also resources.
(cherry picked from commit 5485085b32)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-01-11 06:01:50 -08:00
Miss Islington (bot) 88ad48bc98
bpo-32710: Fix leak in Overlapped_WSASend() (GH-11469)
Fix a memory leak in asyncio in the ProactorEventLoop when ReadFile()
or WSASend() overlapped operation fail immediately: release the
internal buffer.
(cherry picked from commit a234e14839)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-01-08 05:40:50 -08:00
Miss Islington (bot) 6d04bc9a2e
closes bpo-35643: Fix a SyntaxWarning: invalid escape sequence in Modules/_sha3/cleanup.py (GH-11411)
(cherry picked from commit d466c43e55)

Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
2019-01-02 11:58:58 -08:00
Gregory P. Smith efcf08d8ca
[3.7] bpo-35214: Annotate posix calls for clang MSan. (GH-11389) (GH-11391)
It doesn't know the details of a few less common libc functions..

(cherry picked from commit 1d300ce1d8)

Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
2018-12-30 22:14:33 -08:00
Miss Islington (bot) d82344378a
bpo-35550: Fix incorrect Solaris define guards (GH-11275)
Python source code uses on several places ifdef sun or defined(sun) without the underscores, which is not standard compliant and shouldn't be used.

Defines should check for __sun instead. Reference: http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_systemGH-Solaris

https://bugs.python.org/issue35550
(cherry picked from commit 6f9bc72c79)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2018-12-30 18:39:00 -08:00
Miss Islington (bot) a144feeb7e bpo-28503: Use crypt_r() when available instead of crypt() (GH-11373) (GH-11376)
Use crypt_r() when available instead of crypt() in the crypt module.

As a nice side effect: This also avoids a memory sanitizer flake as clang msan doesn't know about crypt's internal libc allocated buffer.
(cherry picked from commit 387512c7ec)

Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
2018-12-30 17:59:52 -08:00
Miss Islington (bot) 01b9664740 bpo-35214: MSan workarounds for socket, time, and test_faulthandler. (GH-11375) (GH-11378)
Add Clang Memory Sanitizer build instrumentation to work around
false positives from the socket and time modules as well as skipping
a couple test_faulthandler tests.
(cherry picked from commit b474e6774d)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2018-12-30 17:59:19 -08:00