Commit Graph

6611 Commits

Author SHA1 Message Date
Miss Islington (bot) 1c70d40e94
bpo-26564: fix obsolete comment in traceback.c (GH-23819)
(cherry picked from commit 40125ab325)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
2020-12-17 05:19:58 -08:00
Victor Stinner f0e42ae03c
bpo-32381: Fix PyRun_SimpleFileExFlags() encoding (GH-23642) (GH-23692)
Fix encoding name when running a ".pyc" file on Windows:
PyRun_SimpleFileExFlags() now uses the correct encoding to decode the
filename.

* Add pyrun_file() subfunction.
* Add pyrun_simple_file() subfunction.
* PyRun_SimpleFileExFlags() now calls _Py_fopen_obj() rather than
  _Py_fopen().

(cherry picked from commit b6d98c10ff)
2020-12-08 16:16:05 +01:00
Brandt Bucher 60463e8e4f
bpo-42536: GC track recycled tuples (GH-23623) (GH-23651)
Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector:

- collections.OrderedDict.items
- dict.items
- enumerate
- functools.reduce
- itertools.combinations
- itertools.combinations_with_replacement
- itertools.permutations
- itertools.product
- itertools.zip_longest
- zip

Previously, they could have become untracked by a prior garbage collection.
(cherry picked from commit 226a012d1c)
2020-12-07 20:07:48 +00:00
Miss Islington (bot) 9b34f34aa9
bpo-42521: Add note about 'Python -d' only working on debug builds (GH-23607)
(cherry picked from commit 99b594404d)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-12-02 14:01:23 -08:00
Ronald Oussoren e8b1c038b1
[3.9] bpo-41100: Support macOS 11 and Apple Silicon (GH-22855) (GH-23295)
* [3.9] bpo-41100: Support macOS 11 and Apple Silicon (GH-22855)

Co-authored-by:  Lawrence D’Anna <lawrence_danna@apple.com>

* Add support for macOS 11 and Apple Silicon (aka arm64)

  As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy

* Support building on recent versions of macOS while deploying to older versions

  This allows building installers on macOS 11 while still supporting macOS 10.9..
(cherry picked from commit 41761933c1)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>

* Back port of changes to _decimal to support arm64

* temp_dir is in test.support in 3.9
2020-11-22 11:18:40 +01:00
Christian Heimes 35bf8ea7be
[3.9] bpo-40998: Fix a refleak in create_filter() (GH-23365) (GH-23369)
(cherry picked from commit d1e38d4023)
2020-11-18 09:45:29 -08:00
Miss Islington (bot) 994c68f586
bpo-40998: Address compiler warnings found by ubsan (GH-20929)
Signed-off-by: Christian Heimes <christian@python.org>

Automerge-Triggered-By: GH:tiran
(cherry picked from commit 07f2adedf0)

Co-authored-by: Christian Heimes <christian@python.org>
2020-11-18 08:01:48 -08:00
Irit Katriel 48a9c0eb2a
[3.9] bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395) (GH-23303)
* bpo-39934: backport PR 22395 to 3.9
2020-11-17 19:31:55 +00:00
Victor Stinner 05a5d697f4
bpo-41686: Always create the SIGINT event on Windows (GH-23344) (GH-23347)
bpo-41686, bpo-41713: On Windows, the SIGINT event,
_PyOS_SigintEvent(), is now created even if Python is configured to
not install signal handlers (PyConfig.install_signal_handlers=0 or
Py_InitializeEx(0)).
2020-11-17 18:58:12 +01:00
Miss Islington (bot) e5729aef6f
bpo-42296: On Windows, fix CTRL+C regression (GH-23257)
On Windows, fix a regression in signal handling which prevented to
interrupt a program using CTRL+C. The signal handler can be run in a
thread different than the Python thread, in which case the test
deciding if the thread can handle signals is wrong.

On Windows, _PyEval_SignalReceived() now always sets eval_breaker to
1 since it cannot test _Py_ThreadCanHandleSignals(), and
  eval_frame_handle_pending() always calls
  _Py_ThreadCanHandleSignals() to recompute eval_breaker.
(cherry picked from commit d96a7a8313)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-11-13 06:11:38 -08:00
Inada Naoki 07a44d9572
bpo-42057: Fix peephole optimizer (GH-22802) 2020-10-22 11:06:07 +09:00
Miss Skeleton (bot) c17ff5cad2
bpo-38324: Fix test__locale.py Windows failures (GH-20529)
Use wide-char _W_* fields of lconv structure on Windows
Remove "ps_AF" from test__locale.known_numerics on Windows
(cherry picked from commit f2312037e3)

Co-authored-by: TIGirardi <tiagoigirardi@gmail.com>
2020-10-20 05:07:14 -07:00
Miss Skeleton (bot) f07448bef4
bpo-41894: Fix UnicodeDecodeError while loading native module (GH-22466)
When running in a non-UTF-8 locale, if an error occurs while importing a
native Python module (say because a dependent share library is missing),
the error message string returned may contain non-ASCII code points
causing a UnicodeDecodeError.

PyUnicode_DecodeFSDefault is used for buffers which may contain
filesystem  paths. For consistency with os.strerror(),
PyUnicode_DecodeLocale is used for buffers which contain system error
messages. While the shortname parameter is always encoded in ASCII
according to PEP 489, it is left decoded using PyUnicode_FromString to
minimize the changes and since it should not affect the decoding (albeit
_potentially_ slower).

In dynload_hpux, since the error buffer contains a message generated
from a static ASCII string and the module filesystem path,
PyUnicode_DecodeFSDefault is used instead of PyUnicode_DecodeLocale as
is used elsewhere.

* bpo-41894: Fix bugs in dynload error msg handling

For both dynload_aix and dynload_hpux, properly handle the possibility
that decoding strings may return NULL and when such an error happens,
properly decrement any previously decoded strings and return early.

In addition, in dynload_aix, ensure that we pass the decoded string
*object* pathname_ob to PyErr_SetImportError instead of the original
pathname buffer.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 2d2af320d9)

Co-authored-by: Kevin Adler <kadler@us.ibm.com>
2020-10-14 19:25:45 -07:00
Miss Skeleton (bot) 391a544f2a
bpo-41993: Fix possible issues in remove_module() (GH-22631) (GH-22647)
* PyMapping_HasKey() is not safe because it silences all exceptions and can return incorrect result.
* Informative exceptions from PyMapping_DelItem() are overridden with RuntimeError and
  the original exception raised before calling remove_module() is lost.
* There is a race condition between PyMapping_HasKey() and PyMapping_DelItem().
(cherry picked from commit 8287aadb75)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-14 12:09:44 +03:00
Miss Islington (bot) 7aa534c956
bpo-41819: Fix compiler warning in init_dump_ascii_wstr() (GH-22332)
Fix the compiler warning:

format specifies type `wint_t` (aka `int`) but the argument has type `unsigned int`
(cherry picked from commit c322948892)

Co-authored-by: Samuel Marks <807580+SamuelMarks@users.noreply.github.com>
2020-09-21 01:58:27 -07:00
Pablo Galindo 55e0836849
[3.9] bpo-41631: _ast module uses again a global state (GH-21961) (GH-22258)
Partially revert commit ac46eb4ad6662cf6d771b20d8963658b2186c48c:
"bpo-38113: Update the Python-ast.c generator to PEP384 (gh-15957)".

Using a module state per module instance is causing subtle practical
problems.

For example, the Mercurial project replaces the __import__() function
to implement lazy import, whereas Python expected that "import _ast"
always return a fully initialized _ast module.

Add _PyAST_Fini() to clear the state at exit.

The _ast module has no state (set _astmodule.m_size to 0). Remove
astmodule_traverse(), astmodule_clear() and astmodule_free()
functions..
(cherry picked from commit e5fbe0cbd4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-09-15 20:32:56 +02:00
Miss Islington (bot) b2376f9141
Fix compiler warnings in init_dump_ascii_wstr() (GH-22150)
Fix GCC 9.3 (using -O3) warnings on x86:

initconfig.c: In function ‘init_dump_ascii_wstr’:
initconfig.c:2679:34: warning: format ‘%lc’ expects argument of type
‘wint_t’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2679 |             PySys_WriteStderr("%lc", ch);
initconfig.c:2682:38: warning: format ‘%x’ expects argument of type
‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2682 |             PySys_WriteStderr("\\x%02x", ch);
initconfig.c:2686:38: warning: format ‘%x’ expects argument of type
‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2686 |             PySys_WriteStderr("\\U%08x", ch);
initconfig.c:2690:38: warning: format ‘%x’ expects argument of type
‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2690 |             PySys_WriteStderr("\\u%04x", ch);
(cherry picked from commit 640e8e1d5f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-09-09 03:31:25 -07:00
Miss Islington (bot) 11a82c7220
bpo-41525: Make the Python program help ASCII-only (GH-21836)
(cherry picked from commit 58de1dd6a8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-09-08 17:47:53 -07:00
Miss Islington (bot) d64d78be20
bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements (GH-21850) (GH-22107)
(cherry picked from commit c51db0ea40)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-09-05 00:38:50 +01:00
Miss Islington (bot) 106c1df736
closes bpo-41533: Fix a potential memory leak when allocating a stack (GH-21847)
Free the stack allocated in va_build_stack if do_mkstack fails
and the stack is not a small_stack
(cherry picked from commit 75c80b0bda)

Co-authored-by: Tony Solomonik <tony.solomonik@gmail.com>
2020-09-04 15:56:04 -07:00
Miss Islington (bot) c16a2a1b64
bpo-41681: Fix for `f-string/str.format` error description when using 2 `,` in format specifier (GH-22036) (GH-22041)
* Fixed `f-string/str.format` error description when using two `,` in format specifier.

Co-authored-by: millefalcon <hanish0019@hmail.com>
(cherry picked from commit 0d6aa7f0ee)

Co-authored-by: han-solo <hanish0019@gmail.com>

Co-authored-by: han-solo <hanish0019@gmail.com>
2020-09-01 11:45:59 -04:00
Miss Islington (bot) 901c2eae6e
bpo-41524: fix pointer bug in PyOS_mystr{n}icmp (GH-21845) (GH-21978) 2020-08-30 15:53:09 +09:00
Victor Stinner d2bea2636d
[3.9] bpo-41194: Convert _ast extension to PEP 489 (GH-21807)
* bpo-41194: Convert _ast extension to PEP 489 (GH-21293)

Convert the _ast extension module to PEP 489 "Multiphase
initialization". Replace the global _ast state with a module state.

(cherry picked from commit b1cc6ba73a)

* bpo-41204: Fix compiler warning in ast_type_init() (GH-21307)

(cherry picked from commit 1f76453173)
2020-08-10 15:55:54 +02:00
Miss Islington (bot) f2f6759a78
Fix -Wstrict-prototypes warning in thread_pthread.h. (GH-21477)
(cherry picked from commit ea62a4bd54)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2020-07-15 06:30:26 -07:00
Pablo Galindo 6488a4a3c9
[3.9] bpo-41218: Only mark async code with CO_COROUTINE. (GH-21357) (GH-21362)
3.8.3 had a regression where compiling with
ast.PyCF_ALLOW_TOP_LEVEL_AWAIT woudl agressively mark things are
coroutine even if there were not.
(cherry picked from commit bd46174)

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
2020-07-06 23:30:20 +01:00
Miss Islington (bot) 4981fe36c7
bpo-29778: Ensure python3.dll is loaded from correct locations when Python is embedded (GH-21297)
Also enables using debug build of `python3_d.dll`
Reference: CVE-2020-15523
(cherry picked from commit dcbaa1b49c)

Co-authored-by: Steve Dower <steve.dower@python.org>
2020-07-06 09:52:13 -07:00
Steve Dower 941117aaa3
bpo-21222: Fix improperly merged change so that final hooks are called before types are cleared (GH-21304) 2020-07-03 23:34:46 +01:00
Steve Dower e1d4fdc533
bpo-41162: Clear audit hooks later during finalization (GH-21222)
Co-authored-by: Konge <zkonge@outlook.com>
2020-07-03 22:58:29 +01:00
Miss Islington (bot) 1c776541a8
bpo-41180: Audit code.__new__ when unmarshalling (GH-21271)
(cherry picked from commit d160e0f8e2)

Co-authored-by: tkmikan <36260601+tkmikan@users.noreply.github.com>
2020-07-03 14:16:23 -07:00
Victor Stinner f8599279b6
[3.9] bpo-41194: The _ast module cannot be loaded more than once (GH-21290) (GH-21292)
* bpo-41194: Pass module state in Python-ast.c (GH-21284)

Rework asdl_c.py to pass the module state to functions in
Python-ast.c, instead of using astmodulestate_global.

Handle also PyState_AddModule() failure in init_types().

(cherry picked from commit 74419f0c64)

* bpo-41194: The _ast module cannot be loaded more than once (GH-21290)

Fix a crash in the _ast module: it can no longer be loaded more than
once. It now uses a global state rather than a module state.

* Move _ast module state: use a global state instead.
* Set _astmodule.m_size to -1, so the extension cannot be loaded more
  than once.

(cherry picked from commit 91e1bc18bd)
2020-07-03 16:57:19 +02:00
Guido van Rossum 2a1ee1d970
[3.9] bpo-35975: Only use cf_feature_version if PyCF_ONLY_AST in cf_flags (#21022) 2020-06-27 17:34:30 -07:00
Pablo Galindo dab533d0ee
[3.9] bpo-41076: Pre-feed the parser with the f-string expression location (GH-21054) (GH-21190)
This commit changes the parsing of f-string expressions with the new parser. The parser gets pre-fed with the location of the expression itself (not the f-string, which was what we were doing before). This allows us to completely skip the shifting of the AST nodes after the parsing is completed..
(cherry picked from commit 1f0f4abb11)
2020-06-28 01:15:28 +01:00
Lysandros Nikolaou 5193d0a665
[3.9] bpo-41132: Use pymalloc allocator in the f-string parser (GH-21173) (GH-21183)
(cherry picked from commit 6dcbc2422d)

Automerge-Triggered-By: @pablogsal
2020-06-27 11:35:18 -07:00
Miss Islington (bot) 7329c8c7a2
bpo-41094: Fix decoding errors with audit when open files. (GH-21095)
(cherry picked from commit 6c6810d989)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-06-24 09:45:27 -07:00
Miss Islington (bot) f19ed6b0c7
bpo-41061: Fix incorrect expressions in hashtable (GH-21028)
Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 4901ea9526)

Co-authored-by: Christian Heimes <christian@python.org>
2020-06-22 01:01:48 -07:00
Miss Islington (bot) 9fe5decf5f
bpo-41056: Fix reference to deallocated stack in pathconfig (Coverity) (GH-21013)
Reported by Coverity.  (CID 1457554 RETURN_LOCAL)

path0 is assigned as a pointer to this right before it goes out of scope.
(cherry picked from commit 81328f3070)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2020-06-22 00:47:54 -07:00
Inada Naoki 610a60c601
bpo-36346: Add Py_DEPRECATED to deprecated unicode APIs (GH-20878)
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 2c4928d37e)
2020-06-18 17:30:53 +09:00
Miss Islington (bot) 097b8b6d52
bpo-40985: Show correct SyntaxError text when last line has a LINECONT (GH-20888)
When a file ends with a line that contains a line continuation character
the text of the emitted SyntaxError is empty, contrary to the old
parser, where the error text contained the text of the last line.
(cherry picked from commit 113e2b0a07)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2020-06-15 17:46:44 -07:00
Miss Islington (bot) b498c7f1b3
bpo-36020: Remove snprintf macro in pyerrors.h (GH-20889)
On Windows, GH-include "pyerrors.h" no longer defines "snprintf" and
"vsnprintf" macros.

PyOS_snprintf() and PyOS_vsnprintf() should be used to get portable
behavior.

Replace snprintf() calls with PyOS_snprintf() and replace vsnprintf()
calls with PyOS_vsnprintf().
(cherry picked from commit e822e37946)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-06-15 13:20:10 -07:00
Miss Islington (bot) bab0833d49
bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
bpo-40910, bpo-40953: PyConfig_Clear() clears _orig_argv.
(cherry picked from commit e2d47a0568)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-06-15 08:19:06 -07:00
Miss Islington (bot) c932f5c1e5
bpo-40957: Fix refleak in _Py_fopen_obj() (GH-20827)
Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 9672912e8f)

Co-authored-by: Christian Heimes <christian@python.org>
2020-06-13 09:18:52 -07:00
Miss Islington (bot) 94bb4b7db2
bpo-40834: Fix truncate when sending str object with channel (GH-20555)
(cherry picked from commit 29c117202e)

Co-authored-by: An Long <aisk@users.noreply.github.com>
2020-06-13 05:44:38 -07:00
Łukasz Langa ce5e6f098f
[3.9] bpo-40924: Revert "bpo-39791 native hooks for importlib.resources.files (GH-20576)" (#20760)
This reverts commit 9cf1be46e3 due to
https://bugs.python.org/issue40924.
2020-06-09 19:50:01 +02:00
Victor Stinner 817506432d
bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var (GH-20605) (GH-20725)
(cherry picked from commit 8f023a2f66)

Co-authored-by: Sandro Mani <manisandro@gmail.com>
2020-06-08 19:36:13 +02:00
Victor Stinner dedaac040f
bpo-40910: Export Py_GetArgcArgv() function (GH-20721) (GH-20723)
Export explicitly the Py_GetArgcArgv() function to the C API and
document the function. Previously, it was exported implicitly which
no longer works since Python is built with -fvisibility=hidden.

* Add PyConfig._orig_argv member.
* Py_InitializeFromConfig() no longer calls _PyConfig_Write() twice.
* PyConfig_Read() no longer initializes Py_GetArgcArgv(): it is now
  _PyConfig_Write() responsibility.
* _PyConfig_Write() result type becomes PyStatus instead of void.
* Write an unit test on Py_GetArgcArgv().

(cherry picked from commit e81f6e687d)
2020-06-08 18:44:50 +02:00
Miss Islington (bot) 9cf1be46e3
bpo-39791 native hooks for importlib.resources.files (GH-20576)
* Provide native .files support on SourceFileLoader.

* Add native importlib.resources.files() support to zipimporter. Remove fallback support.

* make regen-all

* 📜🤖 Added by blurb_it.

* Move 'files' into the ResourceReader so it can carry the relevant module name context.

* Create 'importlib.readers' module and add FileReader to it.

* Add zip reader and rely on it for a TraversableResources object on zipimporter.

* Remove TraversableAdapter, no longer needed.

* Update blurb.

* Replace backslashes with forward slashes.

* Incorporate changes from importlib_metadata 2.0, finalizing the interface for extension via get_resource_reader.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 843c277656)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2020-06-07 18:30:08 -07:00
Miss Islington (bot) 90ee51f1cd
bpo-40870: Invalidate usage of some constants with ast.Name (GH-20649)
(cherry picked from commit 68874a8502)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2020-06-06 10:04:38 -07:00
Victor Stinner 6d62dc1ea4
[3.9] bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578) (GH-20618)
* bpo-40826: Add _Py_EnsureTstateNotNULL() macro (GH-20571)

Add _Py_EnsureTstateNotNULL(tstate) macro: call Py_FatalError() if
tstate is NULL, the error message contains the current function name.

(cherry picked from commit 3026cad59b)

* bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)

PyOS_InterruptOccurred() now fails with a fatal error if it is called
with the GIL released.

(cherry picked from commit cbe1296922)
2020-06-03 20:16:39 +02:00
Ammar Askar 20fe5328a3
[3.9] Fix MSVC warnings in pythonrun.c (GH-20587) (GH-20592)
(cherry picked from commit 90d297012b)
2020-06-03 08:34:55 +01:00
Miss Islington (bot) 410b730c20
Make sure that keyword arguments are merged into the arguments dictionary when dict unpacking and keyword arguments are interleaved. (GH-20553) (GH-20569)
(cherry picked from commit db64f12e4d)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2020-06-01 17:07:32 +01:00