Commit Graph

111528 Commits

Author SHA1 Message Date
rtobar 1c83135381
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.
2021-10-13 18:38:36 +02:00
Petr Viktorin 3dee0cb621
[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>
2021-10-13 18:34:01 +02:00
andrei kulakov 6fafc25aea
bpo-24444: fix an error in argparse help when help for an option is blank (GH-28050) 2021-10-13 18:31:51 +02:00
Ben Hoyt b9e687618d
bpo-45239: Fix parsedate_tz when time has more than 2 dots in it (GH-28452)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-10-13 18:21:27 +02:00
Serhiy Storchaka f59ed3c310
bpo-45229: Make tkinter tests discoverable (GH-28637) 2021-10-13 18:12:48 +02:00
Victor Stinner 676201a59f
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.
2021-10-13 17:35:21 +02:00
Victor Stinner 713bb19356
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".
2021-10-13 17:22:14 +02:00
Pablo Galindo Salgado 3901c08114
bpo-45256: Fix cleanup of stolen locals for Python-to-Python calls (GH-28905) 2021-10-13 14:38:41 +01:00
Victor Stinner bbe7497c5a
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
2021-10-13 15:22:35 +02:00
Mark Shannon a8b9350964
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.
2021-10-13 14:19:34 +01:00
Victor Stinner 97308dfcdc
bpo-45434: Move _Py_BEGIN_SUPPRESS_IPH to pycore_fileutils.h (GH-28922) 2021-10-13 15:03:35 +02:00
Victor Stinner 7cdc2a0f4b
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.
2021-10-13 14:09:13 +02:00
Victor Stinner 7733307739
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.
2021-10-13 14:08:18 +02:00
Terry Jan Reedy 380c440875
bpo-20692: Add Programming FAQ entry for 1.__class__ error. (GH-28918)
To avoid error, add either space or parentheses.
2021-10-13 01:14:58 -04:00
Victor Stinner 678433f25e
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.
2021-10-13 05:24:33 +02:00
Victor Stinner c63623a0a6
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>.
2021-10-13 04:37:55 +02:00
Victor Stinner 489176e428
bpo-45434: Convert Py_GETENV() macro to a function (GH-28912)
Avoid calling directly getenv() in the header file.
2021-10-13 03:39:50 +02:00
David Bohman 9c4766772c
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>
2021-10-12 20:10:26 -04:00
Victor Stinner dbe213de7e
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.
2021-10-13 01:52:22 +02:00
180909 2d21612f0d
Fix spelling in Misc (GH-28858) 2021-10-12 11:22:05 -07:00
Alberto Mardegan 562c0d7398
bpo-45421: Remove dead code from html.parser (GH-28847)
Support for HtmlParserError was removed back in 2014 with commit
73a4359eb0, however this small block was
missed.
2021-10-12 10:12:21 -07:00
Erlend Egeberg Aasland cfb1df3b71
bpo-44991: Normalise function and collation callback naming (GH-28209) 2021-10-12 13:38:49 +02:00
180909 b37dc9b3bc
bpo-45441: Update some moved URLs in documentation (GH-28861) 2021-10-12 13:36:14 +03:00
nobodyatandnothing 1b11582f0e
Slight correct grammar (GH-28860) 2021-10-12 12:29:29 +03:00
Serhiy Storchaka f79f3b41c8
Fix format string in _PyImport_LoadDynamicModuleWithSpec() (GH-28863) 2021-10-12 10:20:04 +03:00
Victor Stinner d943d19172
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().
2021-10-12 08:38:19 +02:00
Mike Gilbert be21706f37
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.
2021-10-12 01:24:03 +02:00
Victor Stinner ce3489cfdb
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().
2021-10-12 00:42:23 +02:00
Victor Stinner fb8f208a4d
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().
2021-10-12 00:18:26 +02:00
Victor Stinner 61190e092b
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.
2021-10-12 00:12:00 +02:00
Victor Stinner 1f316ea3b4
bpo-41123: Remove Py_UNICODE_COPY() and Py_UNICODE_FILL() (GH-28887) 2021-10-11 23:36:37 +02:00
Victor Stinner 03ea862b8a
bpo-45434: Python.h no longer includes <stdlib.h> (GH-28888) 2021-10-11 23:30:00 +02:00
Victor Stinner 7103356455
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.
2021-10-11 23:09:40 +02:00
Victor Stinner a9fe1a8e5b
bpo-45412: Update _Py_ADJUST_ERANGE1() comment (GH-28884)
Copy the comment from the removed Py_OVERFLOWED() function.
2021-10-11 23:07:41 +02:00
Victor Stinner 1ebd798fdd
bpo-45410: Add test.support.flush_std_streams() (GH-28885)
support.print_warning() now flushs sys.stdout.
2021-10-11 23:07:21 +02:00
Victor Stinner 47717d1186
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.
2021-10-11 22:51:32 +02:00
Victor Stinner 2f92e2a590
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()
2021-10-11 21:00:25 +02:00
Olaf van der Spek 659812b451
bpo-45351, asyncio: Enhance echo server example, print all addresses (GH-28828) 2021-10-11 20:54:44 +02:00
Dong-hee Na 560a79f94e
Handle error when PyUnicode_GetLength returns a negative value. (GH-28859) 2021-10-11 20:08:38 +09:00
Dong-hee Na ab62051152
bpo-20028: Empty escapechar/quotechar is not allowed for csv.Dialect (GH-28833) 2021-10-11 20:08:15 +09:00
Josephine-Marie d74da9e140
bpo-45411: Update mimetypes.py (GH-28792)
.vtt and .srt files are common subtitle files, used by browsers.
2021-10-11 13:05:28 +02:00
Jens Diemer c7e81fcf95
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>
2021-10-11 13:42:05 +03:00
Mark Shannon fcb3d2ff63
Restore PEP 523 functionality. (GH-28871) 2021-10-11 11:34:02 +01:00
Serhiy Storchaka 9883ca498d
Fix a leak in _PyImport_LoadDynamicModuleWithSpec() after failing PySys_Audit() (GH-28862) 2021-10-11 11:57:27 +03:00
Serhiy Storchaka 15188b115a
bpo-45401: Fix a resource warning in test_logging (GH-28864) 2021-10-11 11:54:44 +03:00
Joongi Kim 1a7892414e
bpo-45416: Fix use of asyncio.Condition() with explicit Lock objects (GH-28850)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-10-10 19:01:41 +03:00
Vinay Sajip 62a667784b
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.
2021-10-10 08:15:24 -07:00
Christophe Nanteuil 0bcc5ade9b
Fix class pattern docs to refer to class patterns (GH-28849) 2021-10-10 22:12:51 +08:00
180909 532403e7c6
Remove repeated 'the' in docs (GH-28852) 2021-10-10 22:05:21 +08:00
Inada Naoki ad970e8623
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>
2021-10-10 17:29:46 +09:00