Commit Graph

5838 Commits

Author SHA1 Message Date
Miss Islington (bot) 117830de33
Bring Python into the new year. (GH-24036) (GH-24052)
(cherry picked from commit de6f20a6de)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2021-01-01 13:40:58 -05:00
Steve Dower 110dd15366
[3.7] bpo-29778: Ensure python3.dll is loaded from correct locations when Python is embedded (GH-21297) (#21298)
* bpo-29778: Ensure python3.dll is loaded from correct locations when Python is embedded.

* Add CVE number
2020-07-06 13:24:59 -04:00
Miss Islington (bot) 5aa40e587e
bpo-24048: Save the live exception during import.c's remove_module() (GH-13005)
Save the live exception during the course of remove_module().
(cherry picked from commit 94a64e9cd4)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2020-05-29 12:35:21 -07:00
Batuhan Taskaya 43300148c5
[3.7] bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156). (GH-20192)
(cherry picked from commit 2135e10dc7)

Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
2020-05-22 23:32:34 +01:00
Steve Dower 930badd414
bpo-35890: Use RegQueryInfoKeyW and CryptAcquireContextW explicitly (GH-19974)
Co-authored-by: Minmin Gong <gongminmin@msn.com>
2020-05-18 23:24:41 +01:00
Miss Islington (bot) 8e49c1fcf1
bpo-40650: Include winsock2.h in pytime.c, instead of a full windows.h (GH-20137)
(cherry picked from commit f660567937)

Co-authored-by: Minmin Gong <gongminmin@msn.com>
2020-05-18 09:39:13 -07:00
Robert Rouhani d64fd617e0
[3.7] bpo-40417: Fix deprecation warning in PyImport_ReloadModule (GH-19750) (GH-19935)
Use importlib instead of imp.

Automerge-Triggered-By: @brettcannon.
(cherry picked from commit f40bd46)

Co-authored-by: Robert Rouhani robert.rouhani@gmail.com
2020-05-05 17:49:29 -07:00
Victor Stinner d1c09896c3
bpo-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120) (GH-19136) (GH-19137)
PyThreadState.frame is a borrowed reference, not a strong reference:
PyThreadState_Clear() must not call Py_CLEAR(tstate->frame).

Remove test_threading.test_warnings_at_exit(): we cannot warranty
that the Python thread state of daemon threads is cleared in a
reliable way during Python shutdown.

(cherry picked from commit 5804f878e7)
(cherry picked from commit e97c8b0688)
2020-03-24 17:56:01 +01:00
bobince feaf0c3789
[3.7] bpo-39847: EnterNonRecursiveMutex() uses GetTickCount64() (GH-18780) (GH-18959)
The 32-bit (49-day) TickCount relied on in EnterNonRecursiveMutex can overflow
in the gap between the 'target' time and the 'now' time WaitForSingleObjectEx
returns, causing the loop to think it needs to wait another 49 days. This is
most likely to happen when the machine is hibernated during
WaitForSingleObjectEx.

This makes acquiring a lock/event/etc from the _thread or threading module
appear to never timeout.

Replace with GetTickCount64 - this is OK now Python no longer supports XP which
lacks it, and is in use for time.monotonic().

Co-authored-by: And Clover <and.clover@bromium.com>
(cherry picked from commit 64838ce)

Co-authored-by: bobince <and+github@doxdesk.com>
2020-03-12 07:28:31 -07:00
Miss Islington (bot) d0837d2af2
bpo-39520: Fix un-parsing of ext slices with no dimensions (GH-18304)
(cherry picked from commit 185903de12)

Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
2020-03-11 13:16:36 -07:00
Serhiy Storchaka 89fabe51af
[3.7] bpo-39831: Fix a reference leak in PyErr_WarnEx(). (GH-18750). (GH-18765)
(cherry picked from commit 2d2f85517f)
2020-03-08 18:07:58 +02:00
Stefan Krah 852aee69f4
bpo-39776: Lock ++interp->tstate_next_unique_id (GH-18746)
- Threads created by PyGILState_Ensure() could have a duplicate tstate->id.

(cherry picked from commit b3b9ade4a3)
2020-03-03 09:19:58 +01:00
Pablo Galindo 499c926fbe
[3.7] bpo-39831: Fix a reference leak in PyErr_WarnEx(). (GH-18750). (GH-18760)
(cherry picked from commit 2d2f85517f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-03-03 01:13:24 +00:00
Benjamin Peterson 8978ae9705 [3.7] Bring Python into the next decade. (GH-17801). (GH-17803)
(cherry picked from commit 946b29ea0b)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2020-01-02 22:39:21 -05:00
Pablo Galindo 4b75466f5a
[3.7] Fix elif start column offset when there is an else following (GH-17596) (GH-17601)
(cherry picked from commit 5936a4ce91)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2019-12-14 10:55:00 +00:00
Pablo Galindo 0ed45d0cbf
[3.7] bpo-39031: Include elif keyword when producing lineno/col-offset info for if_stmt (GH-17582) (#17584)
When parsing an "elif" node, lineno and col_offset of the node now point to the "elif" keyword and not to its condition, making it consistent with the "if" node.

https://bugs.python.org/issue39031

Automerge-Triggered-By: @pablogsal.
(cherry picked from commit 025a602af7)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2019-12-13 14:04:14 +00:00
Miss Islington (bot) 9baa870c27
bpo-38979: fix ContextVar "__class_getitem__" method (GH-17497)
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None.

https://bugs.python.org/issue38979

Automerge-Triggered-By: @asvetlov
(cherry picked from commit 28c91631c2)

Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
2019-12-08 03:53:07 -08:00
Miss Islington (bot) 63f09e7628
bpo-38823: Fix refleak in marshal init error path (GH-17260)
(cherry picked from commit 33b671e724)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2019-11-20 02:15:22 -08:00
Serhiy Storchaka 91fc9cf43c
[3.7] bpo-38535: Fix positions for AST nodes for calls without arguments in decorators. (GH-16861). (GH-16930)
(cherry picked from commit 26ae9f6d3d)
2019-10-26 17:30:14 +03:00
Miss Skeleton (bot) 5207cc0ef0
Fix typo in formatter_unicode (GH-16831)
numbers's -> number's
(cherry picked from commit 7320ec05f7)

Co-authored-by: Hansraj Das <raj.das.136@gmail.com>
2019-10-25 10:02:47 -07:00
Serhiy Storchaka 928c68eee6
bpo-38540: Revert a warning if PY_SSIZE_T_CLEAN is not defined. (GH-16876) 2019-10-21 21:41:09 +03:00
Miss Skeleton (bot) 3dec84f40e
bpo-38540: Fix possible leak in PyArg_Parse for "esGH-" and "etGH-". (GH-16869)
(cherry picked from commit 5bc6a7c06e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-10-21 01:56:50 -07:00
Miss Islington (bot) 079a1e6307
Typo fix - implemention should be implementation (GH-16806)
(cherry picked from commit 2798b60c55)

Co-authored-by: Hansraj Das <raj.das.136@gmail.com>
2019-10-15 14:07:40 -07:00
Miss Islington (bot) 08afed7605
Typo fix: "throuhgh" should be "through". (GH-16704)
(cherry picked from commit a8e0d3141e)

Co-authored-by: Hansraj Das <raj.das.136@gmail.com>
2019-10-10 21:01:33 -07:00
Miss Islington (bot) d27a9b1695
bpo-38425: Fix ‘res’ may be used uninitialized warning (GH-16688)
(cherry picked from commit a05fcd3c7a)

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2019-10-10 01:00:41 -07:00
Miss Islington (bot) 443370d8ac
Typo fix: "empy" should be "empty". (GH-16666)
(cherry picked from commit 01171ebd96)

Co-authored-by: Hansraj Das <raj.das.136@gmail.com>
2019-10-08 19:42:15 -07:00
Miss Islington (bot) 13bc1523a7
Fix typo in _warnings.warn_explicit() docstring (GH-16625)
(cherry picked from commit 5dfbb4d503)

Co-authored-by: Hansraj Das <raj.das.136@gmail.com>
2019-10-08 02:25:56 -07:00
Paul Ganssle b7a310d865 bpo-38096: Clean up the "struct sequence" / "named tuple" docs (GH-15895) (GH-15962) 2019-09-11 19:50:51 -07:00
Miss Islington (bot) 8892a1d685
closes bpo-38124: Fix bounds check in PyState_AddModule. (GH-16007)
The >=, checking whether a module index was in already in the module-by-index list, needed to be strict.

Also, fold nested ifs into one and fix some bad spacing.
(cherry picked from commit 39de95b746)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2019-09-11 17:02:50 -07:00
Miss Islington (bot) f3480ad088
[3.8] bpo-37409: fix relative import with no parent (GH-14956) (GH-15913)
Relative imports use resolve_name to get the absolute target name,
which first seeks the current module's absolute package name from the globals:
If __package__ (and __spec__.parent) are missing then
import uses __name__, truncating the last segment if
the module is a submodule rather than a package __init__.py
(which it guesses from whether __path__ is defined).

The __name__ attempt should fail if there is no parent package (top level modules),
if __name__ is '__main__' (-m entry points), or both (scripts).
That is, if both __name__ has no subcomponents and the module does not seem
to be a package __init__ module then import should fail..
(cherry picked from commit 92420b3e67)

Co-authored-by: Ben Lewis <benjimin@users.noreply.github.com>
(cherry picked from commit 0a6693a469)

Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com>
2019-09-11 05:50:14 -07:00
Miss Islington (bot) f8dc3e85ab
bpo-37549: os.dup() fails for standard streams on Windows 7 (GH-15389)
(cherry picked from commit 5be666010e)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-08-23 12:01:38 -07:00
Miss Islington (bot) 843fd85cf7
Adjust builtins.zip() docstring to better communicate its signature (GH-14833)
(cherry picked from commit af2f5b1723)

Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
2019-07-19 11:27:13 -07:00
Pablo Galindo 7d93effeb4 [3.7] bpo-37500: Revert commit 85ed1712e4 (GH-14605)
https://bugs.python.org/issue37500
2019-07-05 12:13:38 -07:00
Victor Stinner 8cbffc4d96
bpo-37467: Fix PyErr_Display() for bytes filename (GH-14504) (GH-14515)
Fix sys.excepthook() and PyErr_Display() if a filename is a bytes
string. For example, for a SyntaxError exception where the filename
attribute is a bytes string.

Cleanup also test_sys:

* Sort imports.
* Rename numruns global var to INTERN_NUMRUNS.
* Add DisplayHookTest and ExceptHookTest test case classes.
* Don't save/restore sys.stdout and sys.displayhook using
  setUp()/tearDown(): do it in each test method.
* Test error case (call hook with no argument) after the success case.

(cherry picked from commit f9b7457bd7)
2019-07-01 17:41:38 +02:00
Steve Dower db4d7ddb01
bpo-37369: Fixes path for sys.executable when running from the Microsoft Store (GH-14450) 2019-06-28 10:02:13 -07:00
Miss Islington (bot) 71589491ad bpo-37267: Do not check for FILE_TYPE_CHAR in os.dup() on Windows (GH-14051) (GH-14141)
On Windows, os.dup() no longer creates an inheritable fd when handling a
character file.
(cherry picked from commit 28fca0c422)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2019-06-17 10:45:04 +02:00
Miss Islington (bot) 81fecf7b7a bpo-37289: Remove 'if False' handling in the peephole optimizer (GH-14099) (GH-14111)
(cherry picked from commit 7a68f8c28b)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-06-15 16:22:34 +01:00
Pablo Galindo 5292179afc
[3.7] bpo-37269: Correctly optimise conditionals with constant booleans (GH-14071) (GH-14073)
Fix a regression introduced by af8646c805 that was causing code of the form:

if True and False:
   do_something()

to be optimized incorrectly, eliminating the block..
(cherry picked from commit 05f8318655)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-06-14 07:18:51 +01:00
Victor Stinner a58db9628d
bpo-36829: Enhance PyErr_WriteUnraisable() (GH-13487)
PyErr_WriteUnraisable() now displays the exception even if displaying
the traceback failed. Moreover, hold a strong reference to sys.stderr
while using it.

Document that an exception must be set when calling
PyErr_WriteUnraisable(), but don't add an assertion to check it at
runtime.

Cleanup: use longer names for variables and create
write_unraisable_exc_file() subfunction.
2019-05-22 18:23:28 +02:00
Miss Islington (bot) 85ed1712e4
bpo-1875: Raise SyntaxError in invalid blocks that will be optimised away (GH-13332)
Move the check for dead conditionals (if 0) to the peephole optimizer
and make sure that the code block is still compiled to report any
existing syntax errors within.
(cherry picked from commit af8646c805)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-05-17 03:59:48 -07:00
Miss Islington (bot) b7e483b6d0
bpo-36791: Safer detection of integer overflow in sum(). (GH-13080)
(cherry picked from commit 29500737d4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-05-12 02:37:15 -07:00
Pablo Galindo 34ed40f2e5
[3.7] bpo-34408: Prevent a null pointer dereference and resource leakage in `PyInterpreterState_New()` (GH-8767) (GH-13237)
* A pointer in `PyInterpreterState_New()` could have been `NULL` when being dereferenced.

* Memory was leaked in `PyInterpreterState_New()` when taking some error-handling code path.
(cherry picked from commit 95d630e)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2019-05-10 21:16:19 +01: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
Miss Islington (bot) b87a8073db bpo-32849: Fix is_valid_fd() on FreeBSD (GH-12852) (GH-12863)
Fix Python Initialization code on FreeBSD to detect properly when
stdin file descriptor (fd 0) is invalid.

On FreeBSD, fstat() must be used to check if stdin (fd 0) is valid.
dup(0) doesn't fail if stdin is invalid in some cases.
(cherry picked from commit 3092d6b263)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2019-04-17 18:30:27 +02:00
Miss Islington (bot) cdd8d4d6dd bpo-36370: Check for PyErr_Occurred() after PyImport_GetModule() (GH-12504) 2019-03-25 22:36:43 +01:00
Zackery Spytz bdb9c497e1 bpo-35284: Fix the error handling in the compiler's compiler_call(). (GH-10625) (GH-12496)
compiler_call() needs to check if an error occurred during the
maybe_optimize_method_call() call.
(cherry picked from commit 97f5de01ad)
2019-03-22 15:20:49 +02: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 9818360ed9
bpo-36262: Fix _Py_dg_strtod() memory leak (goto undfl) (GH-12276) (GH-12331)
Fix an unlikely memory leak on conversion from string to float in the
function _Py_dg_strtod() used by float(str), complex(str),
pickle.load(), marshal.load(), etc.

Fix an unlikely memory leak in _Py_dg_strtod() on "undfl:" label:
rewrite memory management in this function to always release all
memory before exiting the function. Initialize variables to NULL, and
set them to NULL after calling Bfree() at the "cont:" label.

Note: Bfree(NULL) is well defined: it does nothing.

(cherry picked from commit 9776b0636a)
2019-03-14 17:12:01 +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) c851dfc99b
bpo-33316: PyThread_release_lock always fails (GH-6541)
Use correct interpretation of return value from APIs.
(cherry picked from commit 05e922136a)

Co-authored-by: native-api <ivan_pozdeev@mail.ru>
2019-02-02 08:45:50 -08:00