Commit Graph

45584 Commits

Author SHA1 Message Date
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
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
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
Serhiy Storchaka 6fed3c8540
bpo-40182: Remove the _field_types attribute of the NamedTuple class (GH-19368) 2020-04-05 00:43:20 +03: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
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
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
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
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
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 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
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
Barney Gale 00002e6d8b
bpo-39682: make `pathlib.Path` immutable by removing (undocumented) support for "closing" a path by using it as a context manager (GH-18846)
Support for using a path as a context manager remains, and is now a no-op.
2020-04-01 16:10:51 +02:00
Zackery Spytz 975ac326ff
bpo-33262: Deprecate passing None for `s` to shlex.split() (GH-6514)
* bpo-33262: Deprecate passing None for `s` to shlex.split()

This reads the string to split from standard input.

* Update What's New.

* Fix shlex.rst
2020-04-01 09:58:55 -04:00
Steve Dower 3ef4a7e5a7
bpo-40121: Fix exception type in test (GH-19267) 2020-04-01 09:38:26 +01:00
Pablo Galindo 6eb9619c88
Handle when IOCTL_VM_SOCKETS_GET_LOCAL_CID does not exist in "socket" (GH-19270)
Running `test_socket` or anything that depends on it (like python -m
test.pythoninfo) crashes if IOCTL_VM_SOCKETS_GET_LOCAL_CID does not
exist in the socket module.

Automerge-Triggered-By: @pablogsal
2020-03-31 17:48:37 -07:00
Victor Stinner afeaea2d6e
bpo-40094: Add missing import to wait_process() (GH-19268) 2020-04-01 02:26:19 +02:00
Victor Stinner 16d75675d2
bpo-31160: Fix race condition in test_os.PtyTests (GH-19263)
bpo-31160, bpo-40094: Wait until the process completes before closing
the PTY to prevent sending SIGHUP to the child process.
2020-04-01 00:27:18 +02:00
Victor Stinner 40bfdb1594
bpo-40094: Add _bootsubprocess._waitstatus_to_exitcode (GH-19264)
* Add _waitstatus_to_exitcode() helper function to _bootsubprocess.
* Enhance check_output() error message if the command fails.

_bootsubprocess no longer handles WIFSTOPPED() case: it now raises a
ValueError.
2020-03-31 23:45:13 +02:00
Victor Stinner a9f9687a7c
bpo-40094: Enhance threading tests (GH-19260)
* Rewrite test_thread.test_forkinthread() to use
  support.wait_process() and wait for the child process in the main
  thread, not in the spawned thread.
* test_threading now uses support.wait_process() and checks the child
  process exit code to detect crashes.
2020-03-31 21:49:44 +02:00
Victor Stinner 27c6231f58
bpo-40094: Enhance fork and wait tests (GH-19259)
* test_fork1: remove duplicated wait_impl() method: reuse
  fork_wait.py implementation instead.
* Use exit code different than 0 to ensure that we executed the
  expected code path.
2020-03-31 21:46:40 +02:00
Victor Stinner 278c1e159c
bpo-40094: Add test.support.wait_process() (GH-19254)
Moreover, the following tests now check the child process exit code:

* test_os.PtyTests
* test_mailbox.test_lock_conflict()
* test_tempfile.test_process_awareness()
* test_uuid.testIssue8621()
* multiprocessing resource tracker tests
2020-03-31 20:08:12 +02:00
Victor Stinner 01e743d704
bpo-40003: test.bisect_cmd copies Python options (GH-19246)
test.bisect_cmd now copies Python command line options like -O or -W.
Moreover, emit a warning if test.bisect_cmd is used with
-w/--verbose2 option.
2020-03-31 17:25:56 +02:00
Steve Dower 63ba5cccf4
bpo-40121: Fixes audit event raised on creating a new socket (GH-19238) 2020-03-31 12:38:53 +01:00
Pablo Galindo ef67512b40
bpo-40108: Improve the error message in runpy when importing a module that includes the extension (GH-19239) 2020-03-31 12:23:55 +01:00
Curtis Bucher 0c5ad54997
Fix bug in test_collections.py (#19221)
Test in TestChainMap() line 257 did not properly check union behavior.
2020-03-30 09:50:57 -07:00
Dong-hee Na 53e4c91725
bpo-40077: Convert _abc module to use PyType_FromSpec() (GH-19202)
Replace statically allocated types with heap allocated types:
use PyType_FromSpec().

Add a module state to store the _abc_data_type.
Add traverse, clear and free functions to the module.
2020-03-30 16:35:38 +02:00
Ashwin Ramaswami 614f17211c
bpo-39073: validate Address parts to disallow CRLF (#19007)
Disallow CR or LF in email.headerregistry.Address arguments to guard against header injection attacks.
2020-03-29 20:38:41 -04:00
Terry Jan Reedy 34a49aa3e4
bpo-38002: Use False/True for IDLE pyshell bools (GH-19203)
Change 0/1 assignments to 'executing', 'canceled', 'reading', 'endoffile'.
These are not used outside of pyshell. Other bools already use False/True.
Add comment about int needed for Windows call.
Remove self.more, unused in idlelib and code.InteractiveInterpreter.
The latter uses 'more' as a local.
2020-03-28 12:51:21 -04:00
Furkan Önder 34b0598295
bpo-40086: Update/fix test_etree test case in test_typing (GH-19189) 2020-03-28 12:32:36 +00:00
Kyle Stanley b61b818d91
bpo-39812: Remove daemon threads in concurrent.futures (GH-19149)
Remove daemon threads from :mod:`concurrent.futures` by adding
an internal `threading._register_atexit()`, which calls registered functions
prior to joining all non-daemon threads. This allows for compatibility
with subinterpreters, which don't support daemon threads.
2020-03-27 20:31:22 +01:00
Victor Stinner d8ff44ce4c
bpo-40089: Fix threading._after_fork() (GH-19191)
If fork was not called by a thread spawned by threading.Thread,
threading._after_fork() now creates a _MainThread instance for
_main_thread, instead of a _DummyThread instance.
2020-03-27 17:50:42 +01:00
Peter Donis e0b8101492
bpo-1812: Fix newline conversion when doctest.testfile loads from a package whose loader has a get_data method (GH-17385)
This pull request fixes the newline conversion bug originally reported in bpo-1812. When that issue was originally submitted, the open builtin did not default to universal newline mode; now it does, which makes the issue fix simpler, since the only code path that needs to be changed is the one in doctest._load_testfile where the file is loaded from a package whose loader has a get_data method.
2020-03-26 10:53:16 -05:00
Furkan Önder cb6534e1a8
bpo-40067: Improve error messages for multiple star expressions in assignments (GH-19168)
Co-Authored-By: Batuhan Taşkaya <isidentical@gmail.com>
Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
2020-03-26 01:54:31 +00:00
Ram Rachum 89a2209ae6
bpo-40016: re docstring: Clarify relationship of inline and argument flags (#19078)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-03-25 14:44:47 -04:00
Curtis Bucher 8f1ed21ecf
bpo-36144: Add union operators to WeakValueDictionary584 (#19127) 2020-03-24 18:51:29 -07:00
Roman Yurchak 15e5024d04
bpo-40029 mark test_importlib.test_zip as requiring zlib (#19105)
* bpo-40029 mark test_importlib.test_zip as requiring zlib

* Decorate TestZip / TestEgg classes as requiring zlib
2020-03-24 15:02:53 -04:00
Victor Stinner 83d46e0622
bpo-40050: Fix importlib._bootstrap_external (GH-19135)
Remove two unused imports: _thread and _weakref. Avoid creating a new
winreg builtin module if it's already available in sys.modules.

The winreg module is now stored as "winreg" rather than "_winreg".
2020-03-24 18:03:34 +01:00
Victor Stinner 5804f878e7
bpo-20526: Fix PyThreadState_Clear(): don't decref frame (GH-19120)
PyThreadState.frame is a borrowed reference, not a strong reference:
PyThreadState_Clear() must not call Py_CLEAR(tstate->frame).

Remove test_threading.test_warnings_at_exit(): we cannot warranty
that the Python thread state of daemon threads is cleared in a
reliable way during Python shutdown.
2020-03-24 16:32:26 +01:00
Łukasz Langa fd88a026be Python 3.9.0a5
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE4/8oOcBIslwITevpsmmV4xAlBWgFAl544Y4ACgkQsmmV4xAl
 BWib5Q//SUfuC1VL72wNZTECCaNGIxcc1eivlXQsNFgPa5pfeCYT0sGVwWpYPsgp
 tAQs69Azns4LRkHR9FehklXkIKMNcrn2rYph6CGhdN+9k9J1AmVSWnjNnpXGl7xT
 UkoabQZVY7LYB0FAQvNWVxONGwY2CKGebm06rLB55T9GZa4jsiCETaMgLB7rX2Re
 vb7dDZm80Eg+zy4U3Vl936O+IEdBnVhVRTQ0FqSDjm8sXZZ+xZpuh7E7QBXfPCNy
 RSKLmw8ru+f8eeJ16LefRNqkk4CUxhvGNxFl2BwVA4PcEIwIMh+0lmbNjJPWFHh6
 BMcvgKW46VrX1gQezYnRt6iosYa5VdPkdO1eXyiN0OPGj4MpPGMGqxF/mlJPQ+7P
 dSkKBOkPUDlztAa3hKTMGcDZ8R1s5FESLYMwu1gnz9IQh+U7NUDrsDd8Nu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YEibtlMKqPhErjHOY90
 Cc+s/NyJgA==
 =zk5D
 -----END PGP SIGNATURE-----

Merge tag 'v3.9.0a5'

Python 3.9.0a5
2020-03-23 23:00:18 +01:00
Curtis Bucher 25e580a73c
bpo-36144: Add union operators to WeakKeyDictionary (#19106) 2020-03-23 13:49:46 -07:00
Curtis Bucher f393b2c588
bpo-36144: Add PEP 584 operators to collections.ChainMap (#18832)
* Update ChainMap to include | and |=

Created __ior__, __or__ and __ror__ methods in ChainMap class.

* Update ACKS

* Update docs

* Update test_collections.py to include test_issue584().

Added testing for | and |= operators for ChainMap objects.

* Update test_union_operators

Renamed test_union operators, fixed errors and style problems raised by brandtbucher.

* Update test_union_operators in TestChainMap

Added testing for union operator between ChainMap and iterable of key-value pairs.

* Update test_union operators in test_collections.py

Gave more descriptive variable names and eliminated unnecessary tmp variable.

* Update test_union_operators in test_collections.py

Added cm3

* Check .maps rather than Chainmap equality.

* Add news entry

* Update Lib/test/test_collections.py

Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com>

* Removed whitespace

* Added Guido's changes

* Fixed Docs

* Removed whitespace

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2020-03-23 12:02:05 -07:00
Łukasz Langa dcd4c4f9c9
Python 3.9.0a5 2020-03-23 17:19:13 +01:00