Commit Graph

26183 Commits

Author SHA1 Message Date
Ethan Smith e3ec44d692
bpo-39481: PEP 585 for difflib, filecmp, fileinput (#19422) 2020-04-09 21:47:31 -07:00
Ethan Smith 7c4185d62d
bpo-39481: PEP 585 for enumerate, AsyncGeneratorType, mmap (GH-19421) 2020-04-09 21:25:53 -07:00
Batuhan Taşkaya 2fa67df605
bpo-39481: PEP 585 for ipaddress.py (GH-19418) 2020-04-09 21:04:54 -07:00
Ethan Smith a8403d057d
Generic itertools.chain (GH-19417) 2020-04-09 20:28:08 -07:00
pxinwr 5cd2803009
bpo-31904: Fix test_c_locale_coercion encodings for VxWorks RTOS (GH-19448) 2020-04-09 17:46:23 +02:00
Serhiy Storchaka a2ec06938f
bpo-40185: Refactor typing.NamedTuple (GH-19371) 2020-04-08 10:59:04 +03: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
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
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
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
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 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
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 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
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
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
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 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
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
Serhiy Storchaka bace59d8b8
bpo-39999: Improve compatibility of the ast module. (GH-19056)
* Re-add removed classes Suite, slice, Param, AugLoad and AugStore.
* Add docstrings for dummy classes.
* Add docstrings for attribute aliases.
* Set __module__ to "ast" instead of "_ast".
2020-03-22 20:33:34 +02:00
Ronald Oussoren 044cf94f61
bpo-22490: Remove __PYVENV_LAUNCHER__ from environment during launch (GH-9516)
* bpo-22490: Remove "__PYVENV_LAUNCHER__" from the shell environment on macOS

This changeset removes the environment varialbe "__PYVENV_LAUNCHER__"
during interpreter launch as it is only needed to communicate between
the stub executable in framework installs and the actual interpreter.

Leaving the environment variable present may lead to misbehaviour when
launching other scripts.

* Actually commit the changes for issue 22490...

* Correct typo

Co-Authored-By: Nicola Soranzo <nicola.soranzo@gmail.com>

* Run make patchcheck

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
2020-03-22 14:31:46 -04:00
Serhiy Storchaka b33e52511a
bpo-36543: Remove the xml.etree.cElementTree module. (GH-19108) 2020-03-22 14:31:38 +02:00
Victor Stinner 7bf069b611
bpo-40019: Skip test_gdb if Python was optimized (GH-19081)
test_gdb now skips tests if it detects that gdb failed to read debug
information because the Python binary is optimized.
2020-03-20 08:23:26 +01:00
Batuhan Taşkaya 9052f7a41b
bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-03-19 11:35:44 +00:00
Batuhan Taşkaya 0ac59f93c0
bpo-40000: Improve error messages when validating invalid ast.Constant nodes (GH-19055)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-03-19 11:32:28 +00:00
Pablo Galindo d112c600ab
bpo-39220: Do not optimise annotation if 'from __future__ import annotations' is used (GH-17866)
Do not apply AST-based optimizations if 'from __future__ import annotations' is used in order to
prevent information lost in the final version of the annotations.
2020-03-18 23:02:09 +00:00