]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
4 years agobpo-45463: Clarify that global statements allows multiple names (GH-28851)
Luca Chiodini [Sat, 16 Oct 2021 12:55:12 +0000 (14:55 +0200)] 
bpo-45463: Clarify that global statements allows multiple names (GH-28851)

The global statement allows specifying a list of identifiers
(https://docs.python.org/3/reference/simple_stmts.html#the-global-statement).

The "Execution model" chapter described the global statement as if it
only allowed one single name. Pluralize "name" in the appropriate places.

4 years agobpo-45442: Add deactivate step to venv tutorial. (GH-28981)
srinivasan [Fri, 15 Oct 2021 21:24:25 +0000 (02:54 +0530)] 
bpo-45442: Add deactivate step to venv tutorial. (GH-28981)

@vsajip Sorry for the trouble—made a [fairly significant] git error in the previous PR.

Have edited the patch as you had said in #28959.

Automerge-Triggered-By: GH:vsajip
4 years agobpo-45440: Remove pymath.c fallbacks (GH-28977)
Victor Stinner [Fri, 15 Oct 2021 17:45:34 +0000 (19:45 +0200)] 
bpo-45440: Remove pymath.c fallbacks (GH-28977)

Remove fallbacks for missing round(), copysign() and hypot() in
Python/pymath.c. Python now requires these functions to build.

These fallbacks were needed on Visual Studio 2012 and older. They are
no longer needed since Visual Stuido 2013. Python is now built with
Visual Studio 2017 or newer since Python 3.6.

4 years agobpo-30459: Use (void) in macros setting variables (GH-28982)
Victor Stinner [Fri, 15 Oct 2021 17:44:35 +0000 (19:44 +0200)] 
bpo-30459: Use (void) in macros setting variables (GH-28982)

Convert the result of macros setting variables to void to avoid risks
of misusing them:

* _PyGCHead_SET_NEXT()
* asdl_seq_SET()
* asdl_seq_SET_UNTYPED()

4 years agobpo-43760: Add PyThreadState_EnterTracing() (GH-28542)
Victor Stinner [Fri, 15 Oct 2021 14:06:30 +0000 (16:06 +0200)] 
bpo-43760: Add PyThreadState_EnterTracing() (GH-28542)

Add PyThreadState_EnterTracing() and PyThreadState_LeaveTracing()
functions to the limited C API to suspend and resume tracing and
profiling.

Add an unit test on the PyThreadState C API to _testcapi.

Add also internal _PyThreadState_DisableTracing() and
_PyThreadState_ResetTracing().

4 years agobpo-45482: Rename namespaceobject.h to pycore_namespace.h (GH-28975)
Victor Stinner [Fri, 15 Oct 2021 13:21:21 +0000 (15:21 +0200)] 
bpo-45482: Rename namespaceobject.h to pycore_namespace.h (GH-28975)

Rename Include/namespaceobject.h to
Include/internal/pycore_namespace.h.

The _testmultiphase extension is now built with the
Py_BUILD_CORE_MODULE macro defined to access _PyNamespace_Type.

object.c: remove unused "pycore_context.h" include.

4 years agobpo-44113: Move the What's New entry to Deprecate section (GH-28974)
Victor Stinner [Fri, 15 Oct 2021 11:43:44 +0000 (13:43 +0200)] 
bpo-44113: Move the What's New entry to Deprecate section (GH-28974)

4 years agobpo-45445: Remove incorrectly commited test file (GH-28972)
Pablo Galindo Salgado [Fri, 15 Oct 2021 11:18:22 +0000 (12:18 +0100)] 
bpo-45445: Remove incorrectly commited test file (GH-28972)

4 years agobpo-45434: Remove Include/eval.h header file (GH-28973)
Victor Stinner [Fri, 15 Oct 2021 11:06:05 +0000 (13:06 +0200)] 
bpo-45434: Remove Include/eval.h header file (GH-28973)

Move Include/eval.h content into Include/ceval.h and
Include/cpython/ceval.h, and remove Include/eval.h.

4 years agobpo-35081: Move interpreteridobject.h to Include/internal/ (GH-28969)
Victor Stinner [Fri, 15 Oct 2021 09:56:34 +0000 (11:56 +0200)] 
bpo-35081: Move interpreteridobject.h to Include/internal/ (GH-28969)

Move the interpreteridobject.h header file from Include/ to
Include/internal/. It only provides private functions.

4 years agobpo-45428: Fix reading filenames from stdin in py_compile (GH-28848)
Graham Inggs [Fri, 15 Oct 2021 09:38:55 +0000 (11:38 +0200)] 
bpo-45428: Fix reading filenames from stdin in py_compile (GH-28848)

Strip trailing '\n'.

4 years agobpo-35134: Move classobject.h to Include/cpython/ (GH-28968)
Victor Stinner [Fri, 15 Oct 2021 07:46:29 +0000 (09:46 +0200)] 
bpo-35134: Move classobject.h to Include/cpython/ (GH-28968)

Move classobject.h, context.h, genobject.h and longintrepr.h header
files from Include/ to Include/cpython/.

Remove redundant "#ifndef Py_LIMITED_API" in context.h.

Remove explicit #include "longintrepr.h" in C files. It's not needed,
Python.h already includes it.

4 years agobpo-45479: Futher simplify Py_UniversalNewlineFgets. (GH-28967)
Benjamin Peterson [Fri, 15 Oct 2021 06:10:52 +0000 (23:10 -0700)] 
bpo-45479: Futher simplify Py_UniversalNewlineFgets. (GH-28967)

Thank you to Eryk Sun for the suggestions in https://github.com/python/cpython/pull/28965#discussion_r729527143.

4 years agocloses bpo-45479: Degunkify Py_UniversalNewlineFgets. (GH-28965)
Benjamin Peterson [Fri, 15 Oct 2021 04:28:52 +0000 (21:28 -0700)] 
closes bpo-45479: Degunkify Py_UniversalNewlineFgets. (GH-28965)

Remove dead variables and control flow.

4 years agobpo-35134: Move Include/cellobject.h to Include/cpython/ (GH-28964)
Victor Stinner [Fri, 15 Oct 2021 00:39:58 +0000 (02:39 +0200)] 
bpo-35134: Move Include/cellobject.h to Include/cpython/ (GH-28964)

4 years agopo-35134: Move Include/funcobject.h to Include/cpython/ (GH-28958)
Victor Stinner [Thu, 14 Oct 2021 23:50:28 +0000 (01:50 +0200)] 
po-35134: Move Include/funcobject.h to Include/cpython/ (GH-28958)

Remove redundant "#ifndef Py_LIMITED_API" in funcobject.h.

4 years agobpo-45434: Remove useless space in includes (GH-28963)
Victor Stinner [Thu, 14 Oct 2021 23:50:04 +0000 (01:50 +0200)] 
bpo-45434: Remove useless space in includes (GH-28963)

Micro-optimize spaces!

4 years agobpo-41710: Fix What's New Entry credit (GH-28962)
Victor Stinner [Thu, 14 Oct 2021 23:49:32 +0000 (01:49 +0200)] 
bpo-41710: Fix What's New Entry credit (GH-28962)

Fix bad copy/paste.

4 years agobpo-45434: Limited Python.h no longer includes stdio.h (GH-28960)
Victor Stinner [Thu, 14 Oct 2021 23:09:06 +0000 (01:09 +0200)] 
bpo-45434: Limited Python.h no longer includes stdio.h (GH-28960)

The <Python.h> header file no longer includes <stdio.h> if the
Py_LIMITED_API macro is defined.

4 years agobpo-45474: Fix the limited C API of marshal.h (GH-28956)
Victor Stinner [Thu, 14 Oct 2021 22:20:33 +0000 (00:20 +0200)] 
bpo-45474: Fix the limited C API of marshal.h (GH-28956)

Remove two functions from the limited C API:

* PyMarshal_WriteLongToFile()
* PyMarshal_WriteObjectToFile()

The PEP 384 excludes functions expecting "FILE*" from the stable ABI.

Remove also the Py_MARSHAL_VERSION macro from the limited C API.

4 years agobpo-35134: Add Include/cpython/floatobject.h (GH-28957)
Victor Stinner [Thu, 14 Oct 2021 21:41:06 +0000 (23:41 +0200)] 
bpo-35134: Add Include/cpython/floatobject.h (GH-28957)

Split Include/floatobject.h into sub-files: add
Include/cpython/floatobject.h and
Include/internal/pycore_floatobject.h.

4 years agobpo-21736: Set __file__ on frozen stdlib modules. (gh-28656)
Eric Snow [Thu, 14 Oct 2021 21:32:18 +0000 (15:32 -0600)] 
bpo-21736: Set __file__ on frozen stdlib modules. (gh-28656)

Currently frozen modules do not have __file__ set.  In their spec, origin is set to "frozen" and they are marked as not having a location.  (Similarly, for frozen packages __path__ is set to an empty list.)  However, for frozen stdlib modules we are able to extrapolate __file__ as long as we can determine the stdlib directory at runtime.  (We now do so since gh-28586.)  Having __file__ set is helpful for a number of reasons.  Likewise, having a non-empty __path__ means we can import submodules of a frozen package from the filesystem (e.g. we could partially freeze the encodings module).

This change sets __file__ (and adds to __path__) for frozen stdlib modules.  It uses sys._stdlibdir (from gh-28586) and the frozen module alias information (from gh-28655).  All that work is done in FrozenImporter (in Lib/importlib/_bootstrap.py).
 Also, if a frozen module is imported before importlib is bootstrapped (during interpreter initialization) then we fix up that module and its spec during the importlib bootstrapping step (i.e. imporlib._bootstrap._setup()) to match what gets set by FrozenImporter, including setting the file info (if the stdlib dir is known).  To facilitate this, modules imported using PyImport_ImportFrozenModule() have __origname__ set using the frozen module alias info.  __origname__ is popped off during importlib bootstrap.

(To be clear, even with this change the new code to set __file__ during fixups in imporlib._bootstrap._setup() doesn't actually get triggered yet.  This is because sys._stdlibdir hasn't been set yet in interpreter initialization at the point importlib is bootstrapped.  However, we do fix up such modules at that point to otherwise match the result of importing through FrozenImporter, just not the __file__ and __path__ parts.  Doing so will require changes in the order in which things happen during interpreter initialization.  That can be addressed separately.  Once it is, the file-related fixup code from this PR will kick in.)

Here are things this change does not do:

* set __file__ for non-stdlib modules (no way of knowing the parent dir)
* set __file__ if the stdlib dir is not known (nor assume the expense of finding it)
* relatedly, set __file__ if the stdlib is in a zip file
* verify that the filename set to __file__ actually exists (too expensive)
* update __path__ for frozen packages that alias a non-package (since there is no package dir)

Other things this change skips, but we may do later:

* set __file__ on modules imported using PyImport_ImportFrozenModule()
* set co_filename when we unmarshal the frozen code object while importing the module (e.g. in FrozenImporter.exec_module()) -- this would allow tracebacks to show source lines
* implement FrozenImporter.get_filename() and FrozenImporter.get_source()

https://bugs.python.org/issue21736

4 years agobpo-45417: [Enum] fix quadratic behavior during creation (GH-28907)
Carl Friedrich Bolz-Tereick [Thu, 14 Oct 2021 20:59:51 +0000 (22:59 +0200)] 
bpo-45417: [Enum] fix quadratic behavior during creation (GH-28907)

Creating an Enum exhibited quadratic behavior based on the number of members in three places:
- `EnumDict._member_names`: a list searched with each new member's name
- member creation: a `for` loop checking each existing member to see if new member was a duplicate
- `auto()` values: a list of all previous values in enum was copied before being sent to `_generate_next_value()`

Two of those issues have been resolved:
- `_EnumDict._member_names` is now a dictionary so lookups are fast
- member creation tries a fast value lookup before falling back to the slower `for` loop lookup

The third issue still remains, as `_generate_next_value_()` can be user-overridden and could corrupt the last values list if it were not copied.

4 years agobpo-45471: Do not set PyConfig.stdlib_dir in Py_SetPythonHome(). (gh-28954)
Eric Snow [Thu, 14 Oct 2021 20:48:32 +0000 (14:48 -0600)] 
bpo-45471: Do not set PyConfig.stdlib_dir in Py_SetPythonHome(). (gh-28954)

The change in gh-28586 (bpo-45211) should not have included code to set _Py_path_config.stdlib_dir in Py_SetPythonHome(). We fix that here.

https://bugs.python.org/issue45471

4 years agobpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893)
Victor Stinner [Thu, 14 Oct 2021 19:53:04 +0000 (21:53 +0200)] 
bpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893)

* Move _PyObject_VectorcallTstate() and _PyObject_FastCallTstate() to
  pycore_call.h (internal C API).
* Convert PyObject_CallOneArg(), PyObject_Vectorcall(),
  _PyObject_FastCall() and PyVectorcall_Function() static inline
  functions to regular functions.
* Add _PyVectorcall_FunctionInline() static inline function.
* PyObject_Vectorcall(), _PyObject_FastCall(), and
  PyObject_CallOneArg() now call _PyThreadState_GET() rather
  than PyThreadState_Get().

4 years agobpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec...
Serhiy Storchaka [Thu, 14 Oct 2021 17:04:19 +0000 (20:04 +0300)] 
bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944)

They support now splitting escape sequences between input chunks.

Add the third parameter "final" in codecs.raw_unicode_escape_decode().
It is True by default to match the former behavior.

4 years agono-issue: Make silence about warning '_POSIX_C_SOURCE redefined' (GH-28948)
Dong-hee Na [Thu, 14 Oct 2021 15:59:56 +0000 (00:59 +0900)] 
no-issue: Make silence about  warning '_POSIX_C_SOURCE redefined' (GH-28948)

4 years agobpo-45367: Specialize BINARY_MULTIPLY (GH-28727)
Dennis Sweeney [Thu, 14 Oct 2021 14:56:33 +0000 (10:56 -0400)] 
bpo-45367: Specialize BINARY_MULTIPLY (GH-28727)

4 years agobpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" codec...
Serhiy Storchaka [Thu, 14 Oct 2021 10:17:00 +0000 (13:17 +0300)] 
bpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" codec (GH-28939)

They support now splitting escape sequences between input chunks.

Add the third parameter "final" in codecs.unicode_escape_decode().
It is True by default to match the former behavior.

4 years agoEnsure that instruction cases are self-contained (GH-28938)
Brandt Bucher [Wed, 13 Oct 2021 22:34:11 +0000 (15:34 -0700)] 
Ensure that instruction cases are self-contained (GH-28938)

4 years agobpo-45440: Require math.h isinf() to build (GH-28894)
Victor Stinner [Wed, 13 Oct 2021 21:27:50 +0000 (23:27 +0200)] 
bpo-45440: Require math.h isinf() to build (GH-28894)

Building Python now requires a C99 <math.h> header file providing
isinf(), isnan() and isfinite() functions.

Remove the Py_FORCE_DOUBLE() macro. It was used by the
Py_IS_INFINITY() macro.

Changes:

* Remove Py_IS_NAN(), Py_IS_INFINITY() and Py_IS_FINITE()
  in PC/pyconfig.h.
* Remove the _Py_force_double() function.
* configure no longer checks if math.h defines isinf(), isnan() and
  isfinite().

4 years agobpo-45434: pyport.h no longer includes <stdlib.h> (GH-28914)
Victor Stinner [Wed, 13 Oct 2021 17:25:53 +0000 (19:25 +0200)] 
bpo-45434: pyport.h no longer includes <stdlib.h> (GH-28914)

Include <stdlib.h> explicitly in C files.

Python.h includes <wchar.h>.

4 years agobpo-45445: Fail if an invalid X-option is provided in the command line (GH-28823)
Pablo Galindo Salgado [Wed, 13 Oct 2021 17:08:19 +0000 (18:08 +0100)] 
bpo-45445: Fail if an invalid X-option is provided in the command line (GH-28823)

4 years agobpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765)
rtobar [Wed, 13 Oct 2021 16:38:36 +0000 (00:38 +0800)] 
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765)

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.

4 years ago[docs] lexical_analysis: Expand the text on ``_`` (GH-28903)
Petr Viktorin [Wed, 13 Oct 2021 16:34:01 +0000 (18:34 +0200)] 
[docs] lexical_analysis: Expand the text on ``_`` (GH-28903)

Also:
* Expand the discussion into its own entry. (Even before this,
  text on ``_`` was longet than the text on ``_*``.)

* Briefly note the other common convention for `_`: naming unused
  variables.

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
4 years agobpo-24444: fix an error in argparse help when help for an option is blank (GH-28050)
andrei kulakov [Wed, 13 Oct 2021 16:31:51 +0000 (12:31 -0400)] 
bpo-24444: fix an error in argparse help when help for an option is blank (GH-28050)

4 years agobpo-45239: Fix parsedate_tz when time has more than 2 dots in it (GH-28452)
Ben Hoyt [Wed, 13 Oct 2021 16:21:27 +0000 (05:21 +1300)] 
bpo-45239: Fix parsedate_tz when time has more than 2 dots in it (GH-28452)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
4 years agobpo-45229: Make tkinter tests discoverable (GH-28637)
Serhiy Storchaka [Wed, 13 Oct 2021 16:12:48 +0000 (19:12 +0300)] 
bpo-45229: Make tkinter tests discoverable (GH-28637)

4 years agobpo-45410: regrtest replaces print_warning.orig_stderr (GH-28926)
Victor Stinner [Wed, 13 Oct 2021 15:35:21 +0000 (17:35 +0200)] 
bpo-45410: regrtest replaces print_warning.orig_stderr (GH-28926)

When running Python tests with -W, runtest() now replaces
support.print_warning.orig_stderr to preserve the messages order.

Add an unit test.

4 years agobpo-45434: Mark the PyTokenizer C API as private (GH-28924)
Victor Stinner [Wed, 13 Oct 2021 15:22:14 +0000 (17:22 +0200)] 
bpo-45434: Mark the PyTokenizer C API as private (GH-28924)

Rename PyTokenize functions to mark them as private:

* PyTokenizer_FindEncodingFilename() => _PyTokenizer_FindEncodingFilename()
* PyTokenizer_FromString() => _PyTokenizer_FromString()
* PyTokenizer_FromFile() => _PyTokenizer_FromFile()
* PyTokenizer_FromUTF8() => _PyTokenizer_FromUTF8()
* PyTokenizer_Free() => _PyTokenizer_Free()
* PyTokenizer_Get() => _PyTokenizer_Get()

Remove the unused PyTokenizer_FindEncoding() function.

import.c: remove unused #include "errcode.h".

4 years agobpo-45256: Fix cleanup of stolen locals for Python-to-Python calls (GH-28905)
Pablo Galindo Salgado [Wed, 13 Oct 2021 13:38:41 +0000 (14:38 +0100)] 
bpo-45256: Fix cleanup of stolen locals for Python-to-Python calls (GH-28905)

4 years agobpo-45434: Remove pystrhex.h header file (GH-28923)
Victor Stinner [Wed, 13 Oct 2021 13:22:35 +0000 (15:22 +0200)] 
bpo-45434: Remove pystrhex.h header file (GH-28923)

Move Include/pystrhex.h to Include/internal/pycore_strhex.h.
The header file only contains private functions.

The following C extensions are now built with Py_BUILD_CORE_MODULE
macro defined to get access to the internal C API:

* _blake2
* _hashopenssl
* _md5
* _sha1
* _sha3
* _ssl
* binascii

4 years agobpo-45340: Don't create object dictionaries unless actually needed (GH-28802)
Mark Shannon [Wed, 13 Oct 2021 13:19:34 +0000 (14:19 +0100)] 
bpo-45340: Don't create object dictionaries unless actually needed (GH-28802)

* Never change types' cached keys. It could invalidate inline attribute objects.

* Lazily create object dictionaries.

* Update specialization of LOAD/STORE_ATTR.

* Don't update shared keys version for deletion of value.

* Update gdb support to handle instance values.

* Rename SPLIT_KEYS opcodes to INSTANCE_VALUE.

4 years agobpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)
Victor Stinner [Wed, 13 Oct 2021 13:03:35 +0000 (15:03 +0200)] 
bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922)

4 years agopycore_pystate.h no longer redefines PyThreadState_GET() (GH-28921)
Victor Stinner [Wed, 13 Oct 2021 12:09:13 +0000 (14:09 +0200)] 
pycore_pystate.h no longer redefines PyThreadState_GET() (GH-28921)

Redefining the PyThreadState_GET() macro in pycore_pystate.h is
useless since it doesn't affect files not including it. Either use
_PyThreadState_GET() directly, or don't use pycore_pystate.h internal
C API. For example, the _testcapi extension don't use the internal C
API, but use the public PyThreadState_Get() function instead.

Replace PyThreadState_Get() with _PyThreadState_GET(). The
_PyThreadState_GET() macro is more efficient than PyThreadState_Get()
and PyThreadState_GET() function calls which call fail with a fatal
Python error.

posixmodule.c and _ctypes extension now include <windows.h> before
pycore header files (like pycore_call.h).

_PyTraceback_Add() now uses _PyErr_Fetch()/_PyErr_Restore() instead
of PyErr_Fetch()/PyErr_Restore().

The _decimal and _xxsubinterpreters extensions are now built with the
Py_BUILD_CORE_MODULE macro defined to get access to the internal C
API.

4 years agobpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)
Victor Stinner [Wed, 13 Oct 2021 12:08:18 +0000 (14:08 +0200)] 
bpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)

support.print_warning() now stores the original value of
sys.__stderr__ and uses it to log warnings. libregrtest uses the same
stream to log unraisable exceptions and uncaught threading
exceptions.

Partially revert commit dbe213de7ef28712bbfdb9d94a33abb9c33ef0c2:
libregrtest no longer replaces sys.__stdout__, sys.__stderr__, and
stdout and stderr file descriptors.

Remove also a few unused imports in libregrtest.

4 years agobpo-20692: Add Programming FAQ entry for 1.__class__ error. (GH-28918)
Terry Jan Reedy [Wed, 13 Oct 2021 05:14:58 +0000 (01:14 -0400)] 
bpo-20692: Add Programming FAQ entry for 1.__class__ error. (GH-28918)

To avoid error, add either space or parentheses.

4 years agobpo-45453: Fix test_embed.StdPrinterTests (GH-28916)
Victor Stinner [Wed, 13 Oct 2021 03:24:33 +0000 (05:24 +0200)] 
bpo-45453: Fix test_embed.StdPrinterTests (GH-28916)

test_embed.StdPrinterTests now always use the file descriptor 1 for
stdout, rather than using sys.__stdout__.fileno().
PyFile_NewStdPrinter() does crash if the argument is not 1 or 2.

Fix also a few pyflakes warnings: remove unused import and variables.

4 years agobpo-45434: bytearrayobject.h no longer includes <stdarg.h> (GH-28913)
Victor Stinner [Wed, 13 Oct 2021 02:37:55 +0000 (04:37 +0200)] 
bpo-45434: bytearrayobject.h no longer includes <stdarg.h> (GH-28913)

bytearrayobject.h and _lzmamodule.c don't use va_list and so don't
need to include <stdarg.h>.

4 years agobpo-45434: Convert Py_GETENV() macro to a function (GH-28912)
Victor Stinner [Wed, 13 Oct 2021 01:39:50 +0000 (03:39 +0200)] 
bpo-45434: Convert Py_GETENV() macro to a function (GH-28912)

Avoid calling directly getenv() in the header file.

4 years agobpo-45405: Prevent ``internal configure error`` when running ``configure`` with...
David Bohman [Wed, 13 Oct 2021 00:10:26 +0000 (17:10 -0700)] 
bpo-45405: Prevent ``internal configure error`` when running ``configure``  with recent versions of non-Apple clang. (#28845)

Change the configure logic to function properly on macOS when the compiler
outputs a platform triplet for option --print-multiarch.

Co-authored-by: Ned Deily <nad@python.org>
4 years agobpo-45410: Enhance libregrtest -W/--verbose3 option (GH-28908)
Victor Stinner [Tue, 12 Oct 2021 23:52:22 +0000 (01:52 +0200)] 
bpo-45410: Enhance libregrtest -W/--verbose3 option (GH-28908)

libregrtest -W/--verbose3 now also replace sys.__stdout__,
sys.__stderr__, and stdout and stderr file descriptors (fd 1 and fd
2).

support.print_warning() messages are now logged in the expected
order.

The "./python -m test test_eintr -W" command no longer logs into
stdout if the test pass.

4 years agoFix spelling in Misc (GH-28858)
180909 [Tue, 12 Oct 2021 18:22:05 +0000 (02:22 +0800)] 
Fix spelling in Misc (GH-28858)

4 years agobpo-45421: Remove dead code from html.parser (GH-28847)
Alberto Mardegan [Tue, 12 Oct 2021 17:12:21 +0000 (20:12 +0300)] 
bpo-45421: Remove dead code from html.parser (GH-28847)

Support for HtmlParserError was removed back in 2014 with commit
73a4359eb0eb624c588c5d52083ea4944f9787ea, however this small block was
missed.

4 years agobpo-44991: Normalise function and collation callback naming (GH-28209)
Erlend Egeberg Aasland [Tue, 12 Oct 2021 11:38:49 +0000 (13:38 +0200)] 
bpo-44991: Normalise function and collation callback naming (GH-28209)

4 years agobpo-45441: Update some moved URLs in documentation (GH-28861)
180909 [Tue, 12 Oct 2021 10:36:14 +0000 (18:36 +0800)] 
bpo-45441: Update some moved URLs in documentation (GH-28861)

4 years agoSlight correct grammar (GH-28860)
nobodyatandnothing [Tue, 12 Oct 2021 09:29:29 +0000 (05:29 -0400)] 
Slight correct grammar (GH-28860)

4 years agoFix format string in _PyImport_LoadDynamicModuleWithSpec() (GH-28863)
Serhiy Storchaka [Tue, 12 Oct 2021 07:20:04 +0000 (10:20 +0300)] 
Fix format string in _PyImport_LoadDynamicModuleWithSpec() (GH-28863)

4 years agobpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)
Victor Stinner [Tue, 12 Oct 2021 06:38:19 +0000 (08:38 +0200)] 
bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)

* Move _PyObject_CallNoArgs() to pycore_call.h (internal C API).
* _ssl, _sqlite and _testcapi extensions now call the public
  PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs().
* _lsprof extension is now built with Py_BUILD_CORE_MODULE macro
  defined to get access to internal _PyObject_CallNoArgs().

4 years agobpo-45433: Do not link libpython against libcrypt (GH-28881)
Mike Gilbert [Mon, 11 Oct 2021 23:24:03 +0000 (19:24 -0400)] 
bpo-45433: Do not link libpython against libcrypt (GH-28881)

Save/restore LIBS when calling AC_SEARCH_LIBS(..., crypt). This avoid
linking libpython with libcrypt.

4 years agobpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)
Victor Stinner [Mon, 11 Oct 2021 22:42:23 +0000 (00:42 +0200)] 
bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)

Fix typo in the private _PyObject_CallNoArg() function name: rename
it to _PyObject_CallNoArgs() to be consistent with the public
function PyObject_CallNoArgs().

4 years agobpo-45439: _PyObject_Call() only checks tp_vectorcall_offset once (GH-28890)
Victor Stinner [Mon, 11 Oct 2021 22:18:26 +0000 (00:18 +0200)] 
bpo-45439: _PyObject_Call() only checks tp_vectorcall_offset once (GH-28890)

Add _PyVectorcall_Call() helper function.

Add "assert(PyCallable_Check(callable));" to PyVectorcall_Call(),
similar check than PyVectorcall_Function().

4 years agobpo-45412: Move copysign() define to pycore_pymath.h (GH-28889)
Victor Stinner [Mon, 11 Oct 2021 22:12:00 +0000 (00:12 +0200)] 
bpo-45412: Move copysign() define to pycore_pymath.h (GH-28889)

Move definitions of copysign(), round(), hypot(), fmod(), etc. from
pymath.h to pycore_pymath.h. These functions are not exported by
libpython and so must not be part of the C API.

4 years agobpo-41123: Remove Py_UNICODE_COPY() and Py_UNICODE_FILL() (GH-28887)
Victor Stinner [Mon, 11 Oct 2021 21:36:37 +0000 (23:36 +0200)] 
bpo-41123: Remove Py_UNICODE_COPY() and Py_UNICODE_FILL() (GH-28887)

4 years agobpo-45434: Python.h no longer includes <stdlib.h> (GH-28888)
Victor Stinner [Mon, 11 Oct 2021 21:30:00 +0000 (23:30 +0200)] 
bpo-45434: Python.h no longer includes <stdlib.h> (GH-28888)

4 years agobpo-45412: Move _Py_SET_53BIT_PRECISION_START to pycore_pymath.h (GH-28882)
Victor Stinner [Mon, 11 Oct 2021 21:09:40 +0000 (23:09 +0200)] 
bpo-45412: Move _Py_SET_53BIT_PRECISION_START to pycore_pymath.h (GH-28882)

Move the following macros , to pycore_pymath.h (internal C API):

* _Py_SET_53BIT_PRECISION_HEADER
* _Py_SET_53BIT_PRECISION_START
* _Py_SET_53BIT_PRECISION_END

PEP 7: add braces to if and "do { ... } while (0)" in these macros.

Move also _Py_get_387controlword() and _Py_set_387controlword()
definitions to pycore_pymath.h. These functions are no longer
exported.

pystrtod.c now includes pycore_pymath.h.

4 years agobpo-45412: Update _Py_ADJUST_ERANGE1() comment (GH-28884)
Victor Stinner [Mon, 11 Oct 2021 21:07:41 +0000 (23:07 +0200)] 
bpo-45412: Update _Py_ADJUST_ERANGE1() comment (GH-28884)

Copy the comment from the removed Py_OVERFLOWED() function.

4 years agobpo-45410: Add test.support.flush_std_streams() (GH-28885)
Victor Stinner [Mon, 11 Oct 2021 21:07:21 +0000 (23:07 +0200)] 
bpo-45410: Add test.support.flush_std_streams() (GH-28885)

support.print_warning() now flushs sys.stdout.

4 years agobpo-45434: Cleanup Python.h header file (GH-28883)
Victor Stinner [Mon, 11 Oct 2021 20:51:32 +0000 (22:51 +0200)] 
bpo-45434: Cleanup Python.h header file (GH-28883)

* Move limits.h include and UCHAR_MAX checks to pyport.h.
* Move sanitizers macros to pyport.h.
* Remove comment about <assert.h>: C extensions are built with NDEBUG
  automatically by Python.

4 years agobpo-45412: Remove Py_SET_ERRNO_ON_MATH_ERROR() macro (GH-28820)
Victor Stinner [Mon, 11 Oct 2021 19:00:25 +0000 (21:00 +0200)] 
bpo-45412: Remove Py_SET_ERRNO_ON_MATH_ERROR() macro (GH-28820)

Remove the following math macros using the errno variable:

* Py_ADJUST_ERANGE1()
* Py_ADJUST_ERANGE2()
* Py_OVERFLOWED()
* Py_SET_ERANGE_IF_OVERFLOW()
* Py_SET_ERRNO_ON_MATH_ERROR()

Create pycore_pymath.h internal header file.

Rename Py_ADJUST_ERANGE1() and Py_ADJUST_ERANGE2() to
_Py_ADJUST_ERANGE1() and _Py_ADJUST_ERANGE2(), and convert these
macros to static inline functions.

Move the following macros to pycore_pymath.h:

* _Py_IntegralTypeSigned()
* _Py_IntegralTypeMax()
* _Py_IntegralTypeMin()
* _Py_InIntegralTypeRange()

4 years agobpo-45351, asyncio: Enhance echo server example, print all addresses (GH-28828)
Olaf van der Spek [Mon, 11 Oct 2021 18:54:44 +0000 (20:54 +0200)] 
bpo-45351, asyncio: Enhance echo server example, print all addresses (GH-28828)

4 years agoHandle error when PyUnicode_GetLength returns a negative value. (GH-28859)
Dong-hee Na [Mon, 11 Oct 2021 11:08:38 +0000 (20:08 +0900)] 
Handle error when PyUnicode_GetLength returns a negative value. (GH-28859)

4 years agobpo-20028: Empty escapechar/quotechar is not allowed for csv.Dialect (GH-28833)
Dong-hee Na [Mon, 11 Oct 2021 11:08:15 +0000 (20:08 +0900)] 
bpo-20028: Empty escapechar/quotechar is not allowed for csv.Dialect (GH-28833)

4 years agobpo-45411: Update mimetypes.py (GH-28792)
Josephine-Marie [Mon, 11 Oct 2021 11:05:28 +0000 (13:05 +0200)] 
bpo-45411: Update mimetypes.py (GH-28792)

.vtt and .srt files are common subtitle files, used by browsers.

4 years agobpo-42253: Update xml.dom.minidom.rst (GH-23126)
Jens Diemer [Mon, 11 Oct 2021 10:42:05 +0000 (12:42 +0200)] 
bpo-42253: Update xml.dom.minidom.rst (GH-23126)

Document that the "standalone" parameter was added in Python 3.9.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
4 years agoRestore PEP 523 functionality. (GH-28871)
Mark Shannon [Mon, 11 Oct 2021 10:34:02 +0000 (11:34 +0100)] 
Restore PEP 523 functionality. (GH-28871)

4 years agoFix a leak in _PyImport_LoadDynamicModuleWithSpec() after failing PySys_Audit() ...
Serhiy Storchaka [Mon, 11 Oct 2021 08:57:27 +0000 (11:57 +0300)] 
Fix a leak in _PyImport_LoadDynamicModuleWithSpec() after failing PySys_Audit() (GH-28862)

4 years agobpo-45401: Fix a resource warning in test_logging (GH-28864)
Serhiy Storchaka [Mon, 11 Oct 2021 08:54:44 +0000 (11:54 +0300)] 
bpo-45401: Fix a resource warning in test_logging (GH-28864)

4 years agobpo-45416: Fix use of asyncio.Condition() with explicit Lock objects (GH-28850)
Joongi Kim [Sun, 10 Oct 2021 16:01:41 +0000 (01:01 +0900)] 
bpo-45416: Fix use of asyncio.Condition() with explicit Lock objects (GH-28850)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
4 years agobpo-45401: Change shouldRollover() methods to only rollover regular f… (GH-28822)
Vinay Sajip [Sun, 10 Oct 2021 15:15:24 +0000 (16:15 +0100)] 
bpo-45401: Change shouldRollover() methods to only rollover regular f… (GH-28822)

…iles.

Also changed some historical return values from 1 -> True and 0 -> False.

4 years agoFix class pattern docs to refer to class patterns (GH-28849)
Christophe Nanteuil [Sun, 10 Oct 2021 14:12:51 +0000 (16:12 +0200)] 
Fix class pattern docs to refer to class patterns (GH-28849)

4 years agoRemove repeated 'the' in docs (GH-28852)
180909 [Sun, 10 Oct 2021 14:05:21 +0000 (22:05 +0800)] 
Remove repeated 'the' in docs (GH-28852)

4 years agobpo-29410: Change the default hash algorithm to SipHash13. (GH-28752)
Inada Naoki [Sun, 10 Oct 2021 08:29:46 +0000 (17:29 +0900)] 
bpo-29410: Change the default hash algorithm to SipHash13. (GH-28752)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Christian Heimes <christian@python.org>
4 years agoFix EncodingWarning in test_tools. (GH-28846)
Inada Naoki [Sun, 10 Oct 2021 07:14:40 +0000 (16:14 +0900)] 
Fix EncodingWarning in test_tools. (GH-28846)

4 years agobpo-45353: Remind sys.modules users to copy when iterating. (GH-28842)
Gregory P. Smith [Sat, 9 Oct 2021 19:34:13 +0000 (12:34 -0700)] 
bpo-45353: Remind sys.modules users to copy when iterating. (GH-28842)

This is true of all dictionaries in Python, but this one tends to
catch people off guard as they don't realize when sys.modules might
change out from underneath them as a hidden side effect of their
code.  Copying it first avoids the RuntimeError.  An example when
this happens in single threaded code are codecs being loaded which
are an implicit time of use import that most need not think about.

4 years agoFix dataclassses spelling (GH-28837)
Landon Yarrington [Sat, 9 Oct 2021 19:17:52 +0000 (13:17 -0600)] 
Fix dataclassses spelling (GH-28837)

4 years agoFix the "Finding all Adverbs" example (GH-21420)
Rim Chatti [Sat, 9 Oct 2021 18:46:56 +0000 (20:46 +0200)] 
Fix the "Finding all Adverbs" example (GH-21420)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
4 years agobpo-45256: Small cleanups for the code that inlines Python-to-Python calls in ceval...
Pablo Galindo Salgado [Sat, 9 Oct 2021 16:52:05 +0000 (17:52 +0100)] 
bpo-45256: Small cleanups for the code that inlines Python-to-Python calls in ceval.c (GH-28836)

4 years agobpo-27580: Add support of null characters in the csv module. (GH-28808)
Serhiy Storchaka [Sat, 9 Oct 2021 16:17:43 +0000 (19:17 +0300)] 
bpo-27580: Add support of null characters in the csv module. (GH-28808)

4 years agobpo-45256: Remove the usage of the C stack in Python to Python calls (GH-28488)
Pablo Galindo Salgado [Sat, 9 Oct 2021 15:51:30 +0000 (16:51 +0100)] 
bpo-45256: Remove the usage of the C stack in Python to Python calls (GH-28488)

Ths commit inlines calls to Python functions in the eval loop and steals all the arguments in the call from the caller for
performance.

4 years agobpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832)
Dong-hee Na [Sat, 9 Oct 2021 15:16:12 +0000 (00:16 +0900)] 
bpo-20028: Keep original exception when PyUnicode_GetLength return -1 (GH-28832)

4 years agobpo-20028: Improve error message of csv.Dialect when initializing (GH-28705)
Dong-hee Na [Sat, 9 Oct 2021 14:50:12 +0000 (23:50 +0900)] 
bpo-20028: Improve error message of csv.Dialect when initializing (GH-28705)

4 years agoBump MAGIC_NUMBER to reflect change in JUMP_ABSOLUTE semantics. (GH-28829)
Mark Shannon [Sat, 9 Oct 2021 13:17:22 +0000 (14:17 +0100)] 
Bump MAGIC_NUMBER to reflect change in JUMP_ABSOLUTE semantics. (GH-28829)

4 years ago[doc]: update susp-ignored.csv after a98b273c. (GH-28827)
Julien Palard [Sat, 9 Oct 2021 08:25:00 +0000 (10:25 +0200)] 
[doc]: update susp-ignored.csv after a98b273c. (GH-28827)

4 years agobpo-10716: Migrating pydoc to html5. (GH-28651)
Julien Palard [Sat, 9 Oct 2021 07:36:50 +0000 (09:36 +0200)] 
bpo-10716: Migrating pydoc to html5. (GH-28651)

4 years agoReplace usage of List[...] with list[...] in typing docs (GH-28821)
Micael Jarniac [Sat, 9 Oct 2021 03:33:37 +0000 (00:33 -0300)] 
Replace usage of  List[...] with list[...] in typing docs (GH-28821)

The ``List[...]`` form is deprecated since 3.9.

4 years agobpo-45410: libregrtest -jN writes stderr into stdout (GH-28819)
Victor Stinner [Fri, 8 Oct 2021 15:14:37 +0000 (17:14 +0200)] 
bpo-45410: libregrtest -jN writes stderr into stdout (GH-28819)

When libregrtest spawns a worker process, stderr is now written into
stdout to keep messages order. Use a single pipe for stdout and
stderr, rather than two pipes. Previously, messages were out of order
which made analysis of buildbot logs harder

4 years agobpo-45407: Remove outdated XXX comment from Struct___init___impl (GH-28805)
Jeong YunWon [Fri, 8 Oct 2021 06:45:11 +0000 (15:45 +0900)] 
bpo-45407: Remove outdated XXX comment from Struct___init___impl (GH-28805)

4 years ago bpo-45262, asyncio: Fix cache of the running loop holder (GH-28796)
Matthias Reichl [Thu, 7 Oct 2021 22:46:49 +0000 (00:46 +0200)] 
 bpo-45262, asyncio: Fix cache of the running loop holder (GH-28796)

Prevent use-after-free of running loop holder via cache.

4 years agobpo-45408: Don't override previous tokenizer errors in the second parser pass (GH...
Pablo Galindo Salgado [Thu, 7 Oct 2021 21:33:05 +0000 (22:33 +0100)] 
bpo-45408: Don't override previous tokenizer errors in the second parser pass (GH-28812)