Commit graph

112284 commits

Author SHA1 Message Date
Eric Snow cb68788dca
bpo-36876: Minor cleanup to c-analyzer "ignored" data.' (gh-31239)
https://bugs.python.org/issue36876
2022-02-09 17:10:53 -07:00
Brandt Bucher 78ae4cc6dc
bpo-46528: Attempt SWAPs at compile-time (GH-30970) 2022-02-09 15:15:36 -08:00
Henry Schreiner 5a3f97291e
bpo-43532: add version added to KW_ONLY (GH-31235)
Minor missing version note mentioned at the end of  (and affected me independently before reading that note).

Automerge-Triggered-By: GH:ericvsmith
2022-02-09 12:56:10 -08:00
Brandt Bucher 46328d8ae6
bpo-46528: Check PyMem_Malloc for NULL (GH-30998) 2022-02-09 11:31:01 -08:00
Dong-hee Na d18120cd67
bpo-46323: Reduce stack usage of ctypes python callback function. (GH-31224) 2022-02-10 03:10:11 +09:00
Joshua Root bf2d44ffb0
bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693)
Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
2022-02-09 18:06:19 +01:00
Kumar Aditya c0a5ebeb12
bpo-46430: Intern strings in deep-frozen modules (GH-30683) 2022-02-09 08:52:42 -08:00
Andrzej Mateja 128ab092ca
bpo-44289: Keep argument file object's current position in tarfile.is_tarfile (GH-26488) 2022-02-09 08:19:16 -08:00
Nikita Sobolev d2d1d49eac
bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223) 2022-02-09 23:23:07 +09:00
Mark Shannon f71a69aa92
bpo-46072: Output stats as markdown with collapsible sections. (GH-31228) 2022-02-09 12:30:26 +00:00
Eric Snow 77bab59c8a
bpo-36876: Update the c-analyzer whitelist. (gh-31225)
This change adds variables that had been added since the last time the whitelist was updated. It also cleans up the list a little.

https://bugs.python.org/issue36876
2022-02-08 18:37:57 -07:00
Barney Gale 06e1701ad3
bpo-46556: emit DeprecationWarning from pathlib.Path.__enter__() (GH-30971)
In Python 3.9, Path.__exit__() was made a no-op and has never been documented.

Co-authored-by: Brett Cannon <brett@python.org>
2022-02-08 13:01:37 -08:00
Eric Snow 81c72044a1
bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized global objects. (gh-30928)
We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code.  It is still used in a number of non-builtin stdlib modules.

The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime.  A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings).

https://bugs.python.org/issue46541#msg411799 explains the rationale for this change.

The core of the change is in:

* (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros
* Include/internal/pycore_runtime_init.h - added the static initializers for the global strings
* Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState
* Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers

I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings.  That check is added to the PR CI config.

The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()).  This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *.

The following are not changed (yet):

* stop using _Py_IDENTIFIER() in the stdlib modules
* (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API
* (maybe) intern the strings during runtime init

https://bugs.python.org/issue46541
2022-02-08 13:39:07 -07:00
Eric Snow c018d3037b
bpo-45952: Get the C analyzer tool working again. (gh-31220)
https://bugs.python.org/issue45952
2022-02-08 12:37:53 -07:00
Jelle Zijlstra 243436f377
bpo-46475: Add typing.Never and typing.assert_never (GH-30842) 2022-02-08 10:50:26 -08:00
Eric Snow 1e6214dbd6
bpo-45952: Get the C analyzer tool working again. (gh-31219)
https://bugs.python.org/issue45952
2022-02-08 11:42:17 -07:00
Dong-hee Na b5527688aa
bpo-46323: Use PyObject_Vectorcall while calling ctypes callback function (GH-31138) 2022-02-08 22:09:17 +09:00
Pablo Galindo Salgado 69e10976b2
bpo-46521: Fix codeop to use a new partial-input mode of the parser (GH-31010) 2022-02-08 11:54:37 +00:00
Mark Shannon 25db2b361b
bpo-46675: Allow object value arrays and split key dictionaries larger than 16 (GH-31191) 2022-02-08 11:50:38 +00:00
Mark Shannon 328fe3fd20
Print summary stats for overall success of specialization. (GH-31211) 2022-02-08 11:50:02 +00:00
Gregory Beauregard c8b62bbe46
bpo-46676: Make ParamSpec args and kwargs equal to themselves (GH-31203) 2022-02-08 09:46:58 +02:00
Dong-hee Na e959dd9f5c
bpo-46323 Fix ref leak if ctypes.CFuncPtr raises an error. (GH-31209) 2022-02-08 14:22:13 +09:00
Jason Wilkes da576e0829
bpo-46678: Fix Invalid cross device link in Lib/test/support/import_helper.py (GH-31204)
In [Lib/test/support/import_helper.py](https://github.com/python/cpython/blob/master/Lib/test/support/import_helper.py), the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this.

Automerge-Triggered-By: GH:brettcannon
2022-02-07 17:09:07 -08:00
Victor Stinner 7a0486eaa9
bpo-46659: calendar uses locale.getlocale() (GH-31166)
The calendar.LocaleTextCalendar and calendar.LocaleHTMLCalendar
classes module now use locale.getlocale(), instead of using
locale.getdefaultlocale(), if no locale is specified.
2022-02-08 00:24:09 +01:00
James Hilton-Balfe 7ba1cc8049
bpo-46534: Implement PEP 673 Self in typing.py (GH-30924)
Co-authored-by: Pradeep Kumar Srinivasan <gohanpra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-02-07 12:47:48 -08:00
Hugo van Kemenade 39dec1c09c
Skip cron workflow for forks (GH-30748) 2022-02-07 13:40:40 -06:00
Steve Dower 3a5afc14e1
bpo-46638: Makes registry virtualisation setting stable when building MSIX packages (GH-31130) 2022-02-07 16:59:40 +00:00
Mark Shannon 9c979d7afd
bpo-46072: Merge dxpairs into py_stats. (GH-31197) 2022-02-07 16:51:43 +00:00
Victor Stinner a89772c791
bpo-46166: Fix compiler warnings in What's New in Python 3.11 (GH-31198)
Fix compiler warnings on PyObject_GetAttrString() calls in the What's
New in Python 3.11 doc of PyFrameObject changes.
2022-02-07 17:46:22 +01:00
Victor Stinner f20ca766fe
bpo-46670: Fix #ifdef in sha3module.c (GH-31180)
* Test if HAVE_ALIGNED_REQUIRED is defined, not its value.
* Define explicitly NOT_PYTHON macro to 0.

Fix "gcc -Wundef" warnings.
2022-02-07 16:22:24 +01:00
Victor Stinner 7d8b69e1d1
bpo-46670: Remove unused macros in the Python directory (GH-31192) 2022-02-07 16:21:52 +01:00
Victor Stinner 760349198d
bpo-46670: Remove unused macros in the Objects directory (GH-31193) 2022-02-07 16:21:41 +01:00
Victor Stinner 4f1d3f33dd
bpo-46670: Remove unused macros in the Modules directory (GH-31194)
* bpo-46670: Remove unused macros in the Modules directory

* Add again LINKAT_DIR_FD_CONVERTER: generated by Argument Clinic
2022-02-07 16:21:31 +01:00
Victor Stinner d3e53bc532
bpo-39277: Fix PY_TIMEOUT_MAX cast in _threadmodule.c (GH-31195)
Cast PY_TIMEOUT_MAX to double, not to _PyTime_t.

Fix the clang warning:

Modules/_threadmodule.c:1648:26: warning: implicit conversion from
'_PyTime_t' (aka 'long') to 'double' changes value from
9223372036854775 to 9223372036854776
[-Wimplicit-const-int-float-conversion]
    double timeout_max = (_PyTime_t)PY_TIMEOUT_MAX * 1e-6;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~ ~
2022-02-07 16:21:09 +01:00
Victor Stinner 4b603f6282
bpo-46670: Remove unused macros in ceval.c (GH-31196)
Remove CHECKEXC() and EXT_POP() macros.
2022-02-07 15:06:27 +00:00
Mark Shannon 062460e8fd
bpo-46072: Improve LOAD_METHOD stats (GH-31104) 2022-02-07 14:30:34 +00:00
Victor Stinner 4cce1352bb
bpo-46323: _ctypes.CFuncPtr fails if _argtypes_ is too long (GH-31188)
ctypes.CFUNCTYPE() and ctypes.WINFUNCTYPE() now fail to create the
type if its "_argtypes_" member contains too many arguments.
Previously, the error was only raised when calling a function.

Change also how CFUNCTYPE() and WINFUNCTYPE() handle KeyError to
prevent creating a chain of exceptions if ctypes.CFuncPtr raises an
error.
2022-02-07 14:53:15 +01:00
Nikita Sobolev 8e98175a03
bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP server (GH-31186)
Re-enable test_issue16464() of test_urllib2, move it to urllib2_localnet
and use the local HTTP server rather than an external HTTP server.
2022-02-07 13:48:43 +01:00
Zackery Spytz 59e004af63
bpo-40479: Fix undefined behavior in Modules/_hashopenssl.c (GH-31153)
va_end() must be called before returning.
2022-02-06 23:40:54 -08:00
Matthew Rahtz a335d98f19
bpo-46589: Improve documentation for typing._GenericAlias (GH-31026)
(These should arguably be docstrings per convention in the rest of the file, but it doesn't really matter.)
2022-02-06 17:59:22 -08:00
Nikita Sobolev 067c03bf40
bpo-46611: add coverage to instance and class checks in typing.py (GH-31078) 2022-02-06 17:35:48 -08:00
Victor Stinner b556f53785
bpo-46670: Test if a macro is defined, not its value (GH-31178)
* audioop.c: #ifdef WORDS_BIGENDIAN
* ctypes.h: #ifdef USING_MALLOC_CLOSURE_DOT_C
* _ctypes/malloc_closure.c: #ifdef HAVE_FFI_CLOSURE_ALLOC
  and #ifdef USING_APPLE_OS_LIBFFI
* pytime.c: #ifdef __APPLE__
* unicodeobject.c: #ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
2022-02-07 01:46:51 +01:00
Victor Stinner 097f74a5a3
bpo-46670: Define all macros for stringlib (GH-31176)
bytesobject.c, bytearrayobject.c and unicodeobject.c now define all
macros used by stringlib, to avoid using undefined macros.
Fix "gcc -Wundef" warnings.
2022-02-07 01:26:58 +01:00
Victor Stinner 16f96a4cf9
bpo-46670: Remove unused get_frame_state() function (GH-31177)
The PyFrame_MAXFREELIST macro is no longer defined.
2022-02-07 01:25:44 +01:00
Gregory Beauregard 77b025be4a
bpo-46655: allow stringized TypeAlias with get_type_hints (GH-31156) 2022-02-06 15:16:22 -08:00
Victor Stinner 06b8f1615b
bpo-46659: test.support avoids locale.getdefaultlocale() (GH-31167)
skip_if_buggy_ucrt_strfptime() of test.support now uses
locale.getpreferredencoding(False) instead of
locale.getdefaultlocale() to get the Windows code page.
2022-02-06 21:51:56 +01:00
Victor Stinner 04dd60e50c
bpo-46659: Update the test on the mbcs codec alias (GH-31168)
encodings registers the _alias_mbcs() codec search function before
the search_function() codec search function. Previously, the
_alias_mbcs() was never used.

Fix the test_codecs.test_mbcs_alias() test: use the current ANSI code
page, not a fake ANSI code page number.

Remove the test_site.test_aliasing_mbcs() test: the alias is now
implemented in the encodings module, no longer in the site module.
2022-02-06 21:50:09 +01:00
Serhiy Storchaka 3da5526136
Add more tests for variable substitution in generics (GH-31170) 2022-02-06 21:52:39 +02:00
Victor Stinner 1578de2fcd
bpo-46648: Skip test_urllib2.test_issue16464() (GH-31161)
POST requests to http://www.example.com/ fail randomly.
2022-02-06 15:08:54 +01:00
Hugo van Kemenade 6c4e44ef8a
bpo-23952: Document cgi module's maxlen variable (GH-30338) 2022-02-06 05:59:32 -08:00