Commit Graph

106971 Commits

Author SHA1 Message Date
Serhiy Storchaka a2ec06938f
bpo-40185: Refactor typing.NamedTuple (GH-19371) 2020-04-08 10:59:04 +03:00
Victor Stinner 307b9d0144
bpo-40170: Remove PyIndex_Check() macro (GH-19428)
Always declare PyIndex_Check() as an opaque function to hide
implementation details: remove PyIndex_Check() macro. The macro
accessed directly the PyTypeObject.tp_as_number member.
2020-04-08 02:26:41 +02:00
Victor Stinner a15e260b70
bpo-40170: Add _PyIndex_Check() internal function (GH-19426)
Add _PyIndex_Check() function to the internal C API: fast inlined
verson of PyIndex_Check().

Add Include/internal/pycore_abstract.h header file.

Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects
and Python subdirectories.
2020-04-08 02:01:56 +02:00
Victor Stinner 45ec5b99ae
bpo-40170: PyType_HasFeature() now always calls PyType_GetFlags() (GH-19378)
PyType_HasFeature() now always calls PyType_GetFlags() to hide
implementation details. Previously, it accessed directly the
PyTypeObject.tp_flags member when the limited C API was not used.

Add fast inlined version _PyType_HasFeature() and _PyType_IS_GC()
for object.c and typeobject.c.
2020-04-08 01:42:27 +02:00
Victor Stinner ef5c615f5a
bpo-40170: Convert PyObject_CheckBuffer() macro to a function (GH-19376)
Convert PyObject_CheckBuffer() macro to a function to hide
implementation details: the macro accessed directly the
PyTypeObject.tp_as_buffer member.
2020-04-08 01:13:53 +02:00
Victor Stinner 9205520d8c
bpo-40170: PyObject_NEW() becomes an alias to PyObject_New() (GH-19379)
The PyObject_NEW() macro becomes an alias to the PyObject_New()
macro, and the PyObject_NEW_VAR() macro becomes an alias to the
PyObject_NewVar() macro, to hide implementation details. They no
longer access directly the PyTypeObject.tp_basicsize member.

Exclude _PyObject_SIZE() and _PyObject_VAR_SIZE() macros from
the limited C API.

Replace PyObject_NEW() with PyObject_New() and replace
PyObject_NEW_VAR() with PyObject_NewVar().
2020-04-08 00:38:15 +02:00
Batuhan Taşkaya f9dd51e7db
bpo-39481: Make os.DirEntry generic (GH-19415) 2020-04-07 14:37:19 -07:00
Victor Stinner 87255be696
bpo-40089: Add _at_fork_reinit() method to locks (GH-19195)
Add a private _at_fork_reinit() method to _thread.Lock,
_thread.RLock, threading.RLock and threading.Condition classes:
reinitialize the lock after fork in the child process; reset the lock
to the unlocked state.

Rename also the private _reset_internal_locks() method of
threading.Event to _at_fork_reinit().

* Add _PyThread_at_fork_reinit() private function. It is excluded
  from the limited C API.
* threading.Thread._reset_internal_locks() now calls
  _at_fork_reinit() on self._tstate_lock rather than creating a new
  Python lock object.
2020-04-07 23:11:49 +02:00
Guido van Rossum 48b069a003
bpo-39481: Implementation for PEP 585 (#18239)
This implements things like `list[int]`,
which returns an object of type `types.GenericAlias`.
This object mostly acts as a proxy for `list`,
but has attributes `__origin__` and `__args__`
that allow recovering the parts (with values `list` and `(int,)`.

There is also an approximate notion of type variables;
e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`.
Type variables are objects of type `typing.TypeVar`.
2020-04-07 09:50:06 -07:00
Victor Stinner 9cc3ebd7e0
bpo-40149: Implement traverse in _abc._abc_data (GH-19412)
Implement traverse and clear slots in _abc._abc_data type.
2020-04-07 18:36:04 +02:00
Victor Stinner d8acf0d9aa
bpo-37388: Don't check encoding/errors during finalization (GH-19409)
str.encode() and str.decode() no longer check the encoding and errors
in development mode or in debug mode during Python finalization. The
codecs machinery can no longer work on very late calls to
str.encode() and str.decode().

This change should help to call _PyObject_Dump() to debug during late
Python finalization.
2020-04-07 16:07:42 +02:00
Rémi Lapeyre 74e1b6b100
Document missing methods of ssl.SSLObject (#19400)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@lenstra.fr>
2020-04-07 09:38:59 +02:00
Zachary Ware f407e209c1
bpo-40214: Temporarily disable a ctypes test (GH-19404)
Only one particular sub-test of
ctypes.test.test_loading.test_load_dll_with_flags is disabled, which
caused failures on Azure Pipelines CI.
2020-04-07 01:39:58 -05:00
amaajemyfren 8ea10a9446
closes bpo-40166: Change Unicode Howto so that it does not have a specific number of assigned code points. (GH-19328)
Change the number of code points from a specific number to a link to the latest standard that has a description of how many code points there are.
2020-04-06 23:16:02 -05:00
Pablo Galindo 799d7d61a9
bpo-40196: Fix a bug in the symtable when reporting inspecting global variables (GH-19391) 2020-04-06 17:05:57 +01:00
Victor Stinner 38aefc585f
bpo-40170: PyObject_GET_WEAKREFS_LISTPTR() becomes a function (GH-19377)
Convert the PyObject_GET_WEAKREFS_LISTPTR() macro to a function to
hide implementation details: the macro accessed directly to the
PyTypeObject.tp_weaklistoffset member.

Add _PyObject_GET_WEAKREFS_LISTPTR() static inline function to the
internal C API.
2020-04-06 14:07:02 +02:00
Zackery Spytz 08050e959e
bpo-40147: Fix a compiler warning on Windows in Python/compile.c (GH-19389)
Change the type of nkeywords to Py_ssize_t.
2020-04-06 07:47:47 +01:00
Raymond Hettinger c63629e7c0
bpo-40197: Better describe the benchmark results table (GH-19386) 2020-04-05 18:53:06 -07:00
Mark Dickinson 810f68f128
Fix misinformation about NaN != NaN comparison (GH-19357) 2020-04-05 10:25:24 +01:00
Batuhan Taşkaya 909f4a3009
bpo-40190: Add support for _SC_AIX_REALMEM in sysconf (GH-19380) 2020-04-05 02:40:49 +02:00
Serhiy Storchaka 6fed3c8540
bpo-40182: Remove the _field_types attribute of the NamedTuple class (GH-19368) 2020-04-05 00:43:20 +03:00
Batuhan Taşkaya 1b21573a89
closes bpo-40184: Only define pysiphash if the hash algorithm is SIPHASH24. (GH-19369) 2020-04-04 16:25:12 -05:00
Hai Shi b709302f31
bpo-40077: Fix potential refleaks of _json: traverse memo (GH-19344)
Fix possible refleaks in _json module, memo of PyScannerObject
should be traversed.
2020-04-04 21:24:16 +02:00
Serhiy Storchaka a94e6272f1
bpo-36517: Raise error on multiple inheritance with NamedTuple (GH-19363) 2020-04-04 21:31:30 +03:00
Raymond Hettinger 1ae6445391
Convert tuples to sets for faster searches (GH-19365) 2020-04-04 11:03:04 -07:00
Steve Dower a1d4dbdfc7
bpo-40164: Update Windows to OpenSSL 1.1.1f (GH-19359) 2020-04-04 15:19:08 +01:00
Tal Einat 52013e5b6d
bpo-38689: avoid IDLE hanging when calltip fails getting a signature (GH-17152)
Inspect.signature failed on the test case because its isinstance call raised.
2020-04-03 23:05:58 -04:00
Chris Martinez 6e623ff9d2
bpo-40158: Fix CPython MSBuild Properties in NuGet Package (GH-19343)
Fix default Python home path relative to the NuGet package
2020-04-03 21:03:54 +01:00
Pablo Galindo 40cf35c5b0
bpo-40141: Include the value in the column position for keyword AST nodes (GH-19348) 2020-04-03 21:02:26 +01:00
Pablo Galindo 254ec78341
bpo-40147: Move the check for duplicate keywords to the compiler (GH-19289) 2020-04-03 20:37:13 +01:00
Zackery Spytz bd6a4c3d72
bpo-40131: Fix source and target order in zipapp example (GH-19290) 2020-04-03 22:06:29 +05:30
Michael Felt 76db37b1d3
bpo-40112: distutils test_search_cpp: Fix logic to determine if C compiler is xlc on AIX (GH-19225) 2020-04-03 16:38:28 +02:00
laike9m b74468e233
bpo-40122: Updated documentation for dis.findlabels() (GH-19274) 2020-04-03 11:00:28 +03:00
Victor Stinner 1767a0490f
bpo-40146: Update OpenSSL to 1.1.1f in Azure Pipelines (GH-19320)
Update also OpenSSL version in Ubuntu and Coverage jobs.
2020-04-03 03:05:10 +02:00
Victor Stinner b1ffb8b723
bpo-40162: Update Travis CI config to OpenSSL 1.1.1f (GH-19319) 2020-04-03 03:03:59 +02:00
Victor Stinner 7a51a7e19f
bpo-40140: test_builtin.PtyTests registers SIGHUP handler (GH-19314)
test_builtin.PtyTests now registers an handler for SIGHUP signal.
Closing the PTY file descriptor can emit a SIGHUP signal: just ignore
it.

run_child() now also closes the PTY file descriptor before waiting
for the process completition, otherwise the test hangs on AIX.
2020-04-03 00:40:25 +02:00
Tim Hatch 3c3aa4516c
lib2to3: Support named assignment expressions (GH-12702)
There are two copies of the grammar -- the one used by Python itself as
Grammar/Grammar, and the one used by lib2to3 which has necessarily diverged at
Lib/lib2to3/Grammar.txt because it needs to support older syntax an we want it
to be reasonable stable to avoid requiring fixer rewrites.

This brings suport for syntax like `if x:= foo():` to match what the live
Python grammar does.

This should've been added at the time of the walrus operator itself, but lib2to3 being
independent is often overlooked.  So we do consider this a bugfix rather than enhancement.
2020-04-02 15:34:54 -07:00
Derek Keeler 45217af29c
bpo-38972: Link to instructions to change PowerShell execution policy (GH-19131) 2020-04-02 12:00:21 -07:00
Hai Shi 7a6f3bcc43
bpo-1635741: Fix refleak in _locale init error handling (GH-19307) 2020-04-02 20:00:47 +02:00
Hai Shi 45f7008a66
bpo-1635741: Port resource extension module to multiphase initialization (PEP 489) (GH-19252)
Fix also reference leaks on error.
2020-04-02 14:35:08 +02:00
Kyle Stanley 8ec7cb53f0
bpo-40115: Fix refleak in test_asyncio.test_run_in_executor_cancel() (GH-19282)
Call explicitly self.loop.shutdown_default_executor().
2020-04-02 04:46:44 +02:00
Victor Stinner e7c98f08e2
bpo-40094: Fix which.py script exit code (GH-19286)
It now uses os.waitstatus_to_exitcode() to convert os.system() exit
status into an exit code.
2020-04-02 03:42:47 +02:00
Victor Stinner 9a679a0e47
bpo-40094: CGIHTTPRequestHandler logs exit code (GH-19285)
CGIHTTPRequestHandler of http.server now logs the CGI script exit
code, rather than the CGI script exit status of os.waitpid().

For example, if the script is killed by signal 11, it now logs:
"CGI script exit code -11."
2020-04-02 03:42:05 +02:00
Dong-hee Na e27916b1fc
bpo-37207: Use PEP 590 vectorcall to speed up dict() (GH-19280) 2020-04-02 02:55:43 +02:00
Victor Stinner 224e1c34d6
bpo-40146: Update OpenSSL to 1.1.1f in Azure Pipelines (GH-19288) 2020-04-02 02:53:33 +02:00
Victor Stinner 0b297d4ff1
bpo-39503: CVE-2020-8492: Fix AbstractBasicAuthHandler (GH-18284)
The AbstractBasicAuthHandler class of the urllib.request module uses
an inefficient regular expression which can be exploited by an
attacker to cause a denial of service. Fix the regex to prevent the
catastrophic backtracking. Vulnerability reported by Ben Caller
and Matt Schwager.

AbstractBasicAuthHandler of urllib.request now parses all
WWW-Authenticate HTTP headers and accepts multiple challenges per
header: use the realm of the first Basic challenge.

Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
2020-04-02 02:52:20 +02:00
Victor Stinner d57cf55736
bpo-40094: mailcap.test() uses waitstatus_to_exitcode() (GH-19287)
mailcap.test() now uses os.waitstatus_to_exitcode() to convert
os.system() exit status into an exit code.
2020-04-02 02:00:06 +02:00
Pablo Galindo 168660b547
bpo-40141: Add line and column information to ast.keyword nodes (GH-19283) 2020-04-02 00:47:39 +01:00
Victor Stinner 65a796e527
bpo-40094: Add os.waitstatus_to_exitcode() (GH-19201)
Add os.waitstatus_to_exitcode() function to convert a wait status to an
exitcode.

Suggest waitstatus_to_exitcode() usage in the documentation when
appropriate.

Use waitstatus_to_exitcode() in:

* multiprocessing, os, subprocess and _bootsubprocess modules;
* test.support.wait_process();
* setup.py: run_command();
* and many tests.
2020-04-01 18:49:29 +02:00
Arnon Yaari 5dd836030e
bpo-38527: fix configure script for Solaris (GH-16845)
On Solaris, the regular "grep" command may be an old version that fails to search a binary file. We need to use the correct command (ggrep, in our case), which is found by the configure script earlier.

Automerge-Triggered-By: @pablogsal
2020-04-01 08:19:09 -07:00