Commit Graph

46742 Commits

Author SHA1 Message Date
Ken Jin a2f0654b0a
bpo-42967: Fix urllib.parse docs and make logic clearer (GH-24536) 2021-02-15 09:00:20 -08:00
Adam Goldschmidt fcbe0cb04d
bpo-42967: only use '&' as a query string separator (#24297)
bpo-42967: [security] Address a web cache-poisoning issue reported in urllib.parse.parse_qsl().

urllib.parse will only us "&" as query string separator by default instead of both ";" and "&" as allowed in earlier versions. An optional argument seperator with default value "&" is added to specify the separator.


Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Éric Araujo <merwok@netwok.org>
2021-02-14 14:41:57 -08:00
Terry Jan Reedy b676f5f809
bpo-43202: More codeop._maybe_compile clean-ups (GH-24512)
Add comment, end others with period, remove unused variables,
initialize others only when needed, and add explicit return.
2021-02-13 01:49:18 -05:00
Gregory P. Smith fd053fdd39
bpo-43172: readline now passes its tests when built against libedit (GH-24499)
bpo-43172: readline now passes its tests when built against libedit.

Existing irreconcilable API differences remain in readline.get_begidx
and readline.get_endidx behavior based on libreadline vs libedit use.
A note about that has been documented.
2021-02-12 12:04:46 -08:00
Terry Jan Reedy 2068b261e9
bpo-43202: Immediately return code object in codeop._maybe_compile (GH-24508)
The return used to be after code that was ignored when there was a code object.
2021-02-11 19:31:10 -05:00
Erlend Egeberg Aasland ea46579067
bpo-40956: Fix segfault when Connection.backup is called without target (GH-24503) 2021-02-11 01:04:02 +02:00
Inada Naoki bdb941be42
bpo-42217: compiler: merge same co_code and co_linetable objects (GH-23056) 2021-02-10 09:20:42 +09:00
Pablo Galindo dbb228189b
bpo-43163: Handle unclosed parentheses in codeop (GH-24483) 2021-02-09 20:07:38 +00:00
Ethan Furman d65b9033d6
bpo-43162: [Enum] deprecate enum member.member access (GH-24486)
In 3.5 (?) a speed optimization made it possible to access members as
attributes of other members, i.e. ``Color.RED.BLUE``.  This was always
discouraged in the docs, and other recent optimizations has made that
one no longer necessary.  Because some may be relying on it anyway, it
is being deprecated in 3.10, and will be removed in 3.11.
2021-02-08 17:32:38 -08:00
Asheesh Laroia bf2e7e55d7
bpo-40692: Run more test_concurrent_futures tests (GH-20239)
In the case of multiprocessing.synchronize() being missing, the
test_concurrent_futures test suite now skips only the tests that
require multiprocessing.synchronize().

Validate that multiprocessing.synchronize exists as part of
_check_system_limits(), allowing ProcessPoolExecutor to raise
NotImplementedError during __init__, rather than crashing with
ImportError during __init__ when creating a lock imported from
multiprocessing.synchronize.

Use _check_system_limits() to disable tests of
ProcessPoolExecutor on systems without multiprocessing.synchronize.

Running the test suite without multiprocessing.synchronize reveals
that Lib/compileall.py crashes when it uses a ProcessPoolExecutor.
Therefore, change Lib/compileall.py to call _check_system_limits()
before creating the ProcessPoolExecutor.

Note that both Lib/compileall.py and Lib/test/test_compileall.py
were attempting to sanity-check ProcessPoolExecutor by expecting
ImportError. In multiprocessing.resource_tracker, sem_unlink() is also absent
on platforms where POSIX semaphores aren't available. Avoid using
sem_unlink() if it, too, does not exist.

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-02-08 03:15:51 +00:00
Raymond Hettinger 30a8b28396
bpo-43147: Remove archaic terminology. (GH-24462) 2021-02-07 16:44:42 -08:00
Pablo Galindo 206cbdab16
bpo-43149: Improve error message for exception group without parentheses (GH-24467) 2021-02-07 18:42:21 +00:00
Zackery Spytz 4bb332cfd1
Fix a typo in a deprecation warning (GH-24423) 2021-02-05 22:09:17 +09:00
Raymond Hettinger d9dda32040
Reduce overhead on random timings (GH-24455) 2021-02-04 21:36:03 -08:00
Raymond Hettinger b6d68aa08b
bpo-43102: Set namedtuple __new__'s internal builtins to a dict. (GH-24439) 2021-02-04 15:52:16 -08:00
Pablo Galindo d4e6ed7e5f
bpo-43121: Fix incorrect SyntaxError message for missing comma (GH-24436) 2021-02-03 23:29:26 +00:00
Harry bfe544d2f2
Fix typo (GH-23019)
Fixed possible typo in comment
2021-02-03 13:25:28 -08:00
Pablo Galindo b0478d738a
Fix Sphynx syntax in the memory.rst document 2021-02-02 20:45:36 +00:00
BarneyStratford 01c4fddc4b
bpo-41149: Fix a bug in threading that causes fals-y threads callables to fail to start. (GH-21201) 2021-02-02 20:24:24 +00:00
Pablo Galindo 58fb156edd
bpo-42997: Improve error message for missing : before suites (GH-24292)
* Add to the peg generator a new directive ('&&') that allows to expect
  a token and hard fail the parsing if the token is not found. This
  allows to quickly emmit syntax errors for missing tokens.

* Use the new grammar element to hard-fail if the ':' is missing before
  suites.
2021-02-02 19:54:22 +00:00
Mark Shannon 802b645e81
Only eliminate jumps to successor block if jump is unconditional. (GH-24417)
* Prevents elimination of the sole test of a value in statements like:
   if x or True: ...
2021-02-02 14:59:15 +00:00
Karl Dubost 9eb11a139f
bpo-41748: Handles unquoted attributes with commas (#24072)
* bpo-41748: Adds tests for unquoted attributes with comma

* bpo-41748: Handles unquoted attributes with comma

* bpo-41748: Addresses review comments

* bpo-41748: Addresses review comments

* Adds more test cases
* Simplifies the regex for handling spaces

* bpo-41748: Moves attributes tests under the right class

* bpo-41748: Addresses review about duplicate attributes

* bpo-41748: Adds NEWS.d entry for this patch
2021-02-01 21:32:50 +01:00
Aviral Srivastava 000cde5984
bpo-38307: Add end_lineno attribute to pyclbr Objects (GH-24348)
For back-compatibility, make the new constructor parameter for public classes Function and Class
keyword-only with a default of None.

Co-authored-by: Aviral Srivastava <aviralsrivastava@Avirals-MacBook-Air.local
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-02-01 12:38:44 -05:00
Yonatan Goldschmidt 574aed16bf
Fix typo in Lib/trace.py (GH-24309) 2021-02-01 21:16:38 +05:30
Ronald Oussoren 49926cf2bc
bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string (GH-24341)
* bpo-42504: Ensure that get_config_var('MACOSX_DEPLOYMENT_TARGET') is a string
2021-01-31 22:29:44 -05:00
Pablo Galindo 835f14ff8e
bpo-43017: Improve error message for unparenthesised tuples in comprehensions (GH24314) 2021-01-31 22:52:56 +00:00
Pablo Galindo 4090151816
bpo-42986: Fix parser crash when reporting syntax errors in f-string with newlines (GH-24279) 2021-01-31 22:48:23 +00:00
Serhiy Storchaka a1e9a1e120
bpo-43016: Fix test_curses on platform without cursesw (GH-24405) 2021-01-31 23:21:55 +02:00
Serhiy Storchaka d64fd4bb5b
bpo-43016: Rewrite tests for curses (GH-24312) 2021-01-31 17:22:27 +02:00
Paul Moore 4d11ecbb5e
bpo-43077: Update bundled pip to 21.0.1 and setuptools to 52.0.0 (GH-24386)
Update bundled pip to 21.0.1 and setuptools to 52.0.0
2021-01-30 16:42:36 +00:00
Steve Dower 62949f697f
bpo-41282: Add deprecation warning and docs for distutils (PEP 632) (GH-24355) 2021-01-29 21:48:55 +00:00
Terry Jan Reedy 11d75ec807
bpo-43008: Add 'Patch by Ken Hilton' (GH-24370) 2021-01-29 13:02:05 -05:00
Mark Shannon d6c33fbd34
bpo-42990: Introduce 'frame constructor' struct to simplify API for PyEval_CodeEval and friends (GH-24298)
* Introduce 'frame constructor' to simplify API for frame creation

* Embed struct using a macro to conform to PEP 7
2021-01-29 13:24:55 +00:00
Zackery Spytz 23a567c11c
bpo-23544: Disable IDLE Stack Viewer when running user code (GH-17163)
Starting stack viewer when user code is running, including when Debugger is active, hangs or crashes IDLE.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-01-28 18:13:22 -05:00
Victor Stinner c9b8e9c421
bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)
* bpo-42979: Enhance abstract.c assertions checking slot result

Add _Py_CheckSlotResult() function which fails with a fatal error if
a slot function succeeded with an exception set or failed with no
exception set: write the slot name, the type name and the current
exception (if an exception is set).
2021-01-27 16:39:16 +00:00
Ken 7a34380ad7
bpo-43008: Make IDLE respect sys.excepthook (GH-24302)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-01-26 18:55:52 -05:00
Ethan Furman 01faf4542a
bpo-38250: [Enum] only include .rst test if file available (GH-24342)
* [Enum] only include .rst test if file available

In order to ensure the ReST documentation is up to date for Enum,
use doctest to check it -- but only if the .rst files have not
been stripped.
2021-01-26 12:52:52 -08:00
Ethan Furman 7aaeb2a3d6
bpo-38250: [Enum] single-bit flags are canonical (GH-24215)
Flag members are now divided by one-bit verses multi-bit, with multi-bit being treated as aliases. Iterating over a flag only returns the contained single-bit flags.

Iterating, repr(), and str() show members in definition order.

When constructing combined-member flags, any extra integer values are either discarded (CONFORM), turned into ints (EJECT) or treated as errors (STRICT). Flag classes can specify which of those three behaviors is desired:

>>> class Test(Flag, boundary=CONFORM):
...     ONE = 1
...     TWO = 2
...
>>> Test(5)
<Test.ONE: 1>

Besides the three above behaviors, there is also KEEP, which should not be used unless necessary -- for example, _convert_ specifies KEEP as there are flag sets in the stdlib that are incomplete and/or inconsistent (e.g. ssl.Options). KEEP will, as the name suggests, keep all bits; however, iterating over a flag with extra bits will only return the canonical flags contained, not the extra bits.

Iteration is now in member definition order.  If member definition order
matches increasing value order, then a more efficient method of flag
decomposition is used; otherwise, sort() is called on the results of
that method to get definition order.


``re`` module:

repr() has been modified to support as closely as possible its previous
output; the big difference is that inverted flags cannot be output as
before because the inversion operation now always returns the comparable
positive result; i.e.

   re.A|re.I|re.M|re.S is ~(re.L|re.U|re.S|re.T|re.DEBUG)

in both of the above terms, the ``value`` is 282.

re's tests have been updated to reflect the modifications to repr().
2021-01-25 14:26:19 -08:00
Victor Stinner 9852cb3811
bpo-42955: Rename module_names to sys.stdlib_module_names (GH-24332)
* Rename _Py_module_names to _Py_stdlib_module_names.
* Rename Python/module_names.h to Python/stdlib_module_names.h.
2021-01-25 23:12:50 +01:00
Andrey Bienkowski 501d4a51e3
bpo-42383: pdb: do not fail to restart the target if the current directory changed (#23412)
This commit only adds tests and a news entry. The actual bug was fixed in the earlier commit.
2021-01-25 13:08:01 -08:00
Serhiy Storchaka f066bd94b9
bpo-37319: Improve documentation, code and tests of randrange. (GH-19112) 2021-01-25 23:02:04 +02:00
Julien Palard eb9983c59b
bpo-42869: Avoid an HTTP redirection. (GH-24174) 2021-01-25 15:50:14 +01:00
Victor Stinner db584bdad3
bpo-42955: Add sys.modules_names (GH-24238)
Add sys.module_names, containing the list of the standard library
module names.
2021-01-25 13:24:42 +01:00
Terry Jan Reedy 879986d8a9
bpo-43013: Fix old tkinter module names in idlelib (GH-24326)
Lowercase 'tkColorChooser', 'tkFileDialog', 'tkSimpleDialog', and
'tkMessageBox' and remove 'tk'.  Just lowercase 'tkFont' as 'font'
is already used.  Adjust import.
2021-01-25 06:33:18 -05:00
Serhiy Storchaka cf19cc3b92
bpo-27772: Make preceding width with 0 valid in string format. (GH-11270)
Previously it was an error with confusing error message.
2021-01-25 11:56:33 +02:00
Terry Jan Reedy 8dfe15625e
bpo-43013: Update idlelib code to 3.x (GH-24315)
Remove 9 remaining '(object)' occurrences in class headers in idlelib
and 25 '()' occurrences in idlelib.idle_test class headers.
2021-01-24 14:08:50 -05:00
Anthony Sottile 15bd9efd01
bpo-43014: Improve performance of tokenize.tokenize by 20-30% 2021-01-24 12:23:17 +03:00
Zackery Spytz f7fa64f0e8
closes bpo-43011: Fix DeprecationWarnings in test_ctypes (GH-24305) 2021-01-23 10:34:01 -06:00
Andrey Bienkowski 8603dfb421
bpo-42384: pdb: correctly populate sys.path[0] (GH-23338)
Automerge-Triggered-By: GH:gvanrossum
2021-01-21 17:19:51 -08:00
Cheryl Sabella 6713e869c4
bpo-33289: Return RGB triplet of ints instead of floats from tkinter.colorchooser (GH-6578) 2021-01-21 21:14:04 +02:00
Batuhan Taskaya a698d52c39
bpo-40176: Improve error messages for unclosed string literals (GH-19346)
Automerge-Triggered-By: GH:isidentical
2021-01-20 13:38:47 -08:00
Victor Stinner 75e59a97f5
bpo-42856: Add --with-wheel-pkg-dir=PATH configure option (GH-24210)
Add --with-wheel-pkg-dir=PATH option to the ./configure script. If
specified, the ensurepip module looks for setuptools and pip wheel
packages in this directory: if both are present, these wheel packages
are used instead of ensurepip bundled wheel packages.

Some Linux distribution packaging policies recommend against bundling
dependencies. For example, Fedora installs wheel packages in the
/usr/share/python-wheels/ directory and don't install the
ensurepip._bundled package.

ensurepip: Remove unused runpy import.
2021-01-20 17:07:21 +01:00
cptpcrd 7dc71c425c
bpo-42780: Fix set_inheritable() for O_PATH file descriptors on Linux (GH-24172) 2021-01-20 15:05:51 +01:00
Zhiming Wang 3554fa4abe
bpo-42005: profile and cProfile catch BrokenPipeError (GH-22643) 2021-01-20 09:56:21 +01:00
Pablo Galindo d6d6371447
bpo-42864: Improve error messages regarding unclosed parentheses (GH-24161) 2021-01-19 23:59:33 +00:00
Victor Stinner 66f77caca3
bpo-42923: _Py_DumpExtensionModules() ignores stdlib ext (GH-24254) 2021-01-19 23:35:27 +01:00
Petr Viktorin 65cf1ad672
bpo-41818: Close file descriptors in test_openpty (#GH-24119)
When stdin is a TTY, the test added in commit c13d89955d
is expected to fail. However, when it failed, it did not close
its file descriptors. This is flagged by the refleak tests (but
only when stdin is a TTY, which doesn't seem to be the case on CI).
2021-01-19 14:03:12 +01:00
Benjamin Peterson 916610ef90
closes bpo-42938: Replace snprintf with Python unicode formatting in ctypes param reprs. (24239) 2021-01-18 14:47:05 -06:00
Victor Stinner 250035d134
bpo-42923: Dump extension modules on fatal error (GH-24207)
The Py_FatalError() function and the faulthandler module now dump the
list of extension modules on a fatal error.

Add _Py_DumpExtensionModules() and _PyModule_IsExtension() internal
functions.
2021-01-18 20:47:13 +01:00
jonanifranco f7b5bacd7a
bpo-42944 Fix Random.sample when counts is not None (GH-24235) 2021-01-18 10:04:29 -08:00
Victor Stinner e232025025
bpo-42923: Add Py_FatalError() test in test_capi (GH-24240)
Move faulthandler._fatal_error() to _testcapi.fatal_error().
2021-01-18 18:24:29 +01:00
Setrak Balian 998ae1fa3f
bpo-42931: randbytes missing from random.__all__ (GH-24219) 2021-01-15 09:50:42 -08:00
Irit Katriel ba876c44a8
bpo-42934: use TracebackException(compact=True) in unittest.TestResult (GH-24221) 2021-01-15 07:59:44 -08:00
Mark Shannon e56d54e447
Mark instructions at end of class scope as artificial. (GH-24222) 2021-01-15 13:52:00 +00:00
Irit Katriel 4c94d74152
bpo-42877: add the 'compact' param to TracebackException's __init__ (#24179)
Use it to reduce the time and memory taken up by several of traceback's module-level functions.
2021-01-14 18:45:02 -08:00
Lysandros Nikolaou e5fe509054
bpo-42827: Fix crash on SyntaxError in multiline expressions (GH-24140)
When trying to extract the error line for the error message there
are two distinct cases:

1. The input comes from a file, which means that we can extract the
   error line by using `PyErr_ProgramTextObject` and which we already
   do.
2. The input does not come from a file, at which point we need to get
   the source code from the tokenizer:
   * If the tokenizer's current line number is the same with the line
     of the error, we get the line from `tok->buf` and we're ready.
   * Else, we can extract the error line from the source code in the
     following two ways:
     * If the input comes from a string we have all the input
       in `tok->str` and we can extract the error line from it.
     * If the input comes from stdin, i.e. the interactive prompt, we
       do not have access to the previous line. That's why a new
       field `tok->stdin_content` is added which holds the whole input for the
       current (multiline) statement or expression. We can then extract the
       error line from `tok->stdin_content` like we do in the string case above.

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-01-14 21:36:30 +00:00
Tobias Holl 61d8c54f43
bpo-42924: Fix incorrect copy in bytearray_repeat (GH-24208)
Before, using the * operator to repeat a bytearray would copy data from the start of
the internal buffer (ob_bytes) and not from the start of the actual data (ob_start).
2021-01-13 18:16:40 +02:00
Mark Shannon 3bd6035b6b
bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202)
* Mark bytecodes at end of try-except as artificial.

* Make sure that the CFG is consistent throughout optimiization. 

* Extend line-number propagation logic so that implicit returns after 'try-except' or 'with' have the correct line numbers.

* Update importlib
2021-01-13 12:05:43 +00:00
Ethan Furman c314e60388
bpo-42901: [Enum] move member creation to `__set_name__` (GH-24196)
`type.__new__` calls `__set_name__` and `__init_subclass__`, which means
that any work metaclasses do after calling `super().__new__()` will not
be available to those two methods.  In particular, `Enum` classes that
want to make use of `__init_subclass__` will not see any members.

Almost all customization is therefore moved to before the
`type.__new__()` call, including changing all members to a proto member
descriptor with a `__set_name__` that will do the final conversion of a
member to be an instance of the `Enum` class.
2021-01-12 23:47:57 -08:00
Hugo van Kemenade c47c78b878
bpo-37324: Remove ABC aliases from collections (GH-23754)
Remove deprecated aliases to Abstract Base Classes from the
collections module.
2021-01-13 00:16:37 +01:00
Irit Katriel 6dfd1734f5
bpo-42848: remove recursion from TracebackException (GH-24158) 2021-01-12 14:14:27 -08:00
Victor Stinner 11d13e83ab
bpo-42882: Add test_embed.test_unicode_id_init() (GH-24198)
Test that _PyUnicode_FromId() works when Python is initialized
multiples times.
2021-01-12 11:26:26 +01:00
Ken Jin ace008c531
Fix various ParamSpec errors in typing (GH-24176)
1. ParamSpec -> TypeVar for ``typing.Concatenate``
2. ParamSpec's call signature should align with its documentation.
Noticed in GH-24169
2021-01-10 16:11:41 -08:00
Terry Jan Reedy 81f87bbf9f
bpo-33065: Fix problem debugging user classes with __repr__ method (GH-24183)
If __repr__ uses instance attributes, as normal, and one steps
through the __init__ method, debugger may try to get repr before
the instance attributes exist.  reprlib.repr handles the error.
2021-01-10 01:59:47 -05:00
Erlend Egeberg Aasland d16f6176ab
bpo-24464: Fix sqlite3.enable_shared_cache() deprecation wrapper (GH-24170) 2021-01-09 13:25:55 +02:00
Victor Stinner 0e2a0f72cc
bpo-42802: Remove distutils bdist_wininst command (GH-24043)
The distutils bdist_wininst command deprecated in Python 3.8 has been
removed. The distutils bidst_wheel command is now recommended to
distribute binary packages on Windows.

* Remove Lib/distutils/command/bdist_wininst.py
* Remove PC/bdist_wininst/ project
* Remove Lib/distutils/command/wininst-*.exe programs
* Remove all references to bdist_wininst
2021-01-09 00:35:01 +01:00
Victor Stinner 07f2cee93f
bpo-42846: Convert CJK codec extensions to multiphase init (GH-24157)
Convert the 6 CJK codec extension modules (_codecs_cn, _codecs_hk,
_codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw) to the
multiphase initialization API (PEP 489).

Remove getmultibytecodec() local cache: always import
_multibytecodec. It should be uncommon to get a codec. For example,
this function is only called once per CJK codec module.

Fix a reference leak in register_maps() error path.
2021-01-08 00:15:22 +01:00
Ethan Furman a581a868d9
bpo-42851: [Enum] remove brittle __init_subclass__ support (GH-24154)
Solution to support calls to `__init_subclass__` with members defined is too brittle and breaks with certain mixins.
2021-01-07 13:17:55 -08:00
Erlend Egeberg Aasland deab1e54ff
bpo-42847: Normalise Lib/sqlite3/test/* file encodings (GH-24147)
Convert from ISO-8859-1 to UTF-8.
2021-01-07 02:36:35 +02:00
Erlend Egeberg Aasland 849e339a92
bpo-40823: Use loadTestsFromTestCase() iso. makeSuite() in sqlite3 tests (GH-20538) 2021-01-07 02:05:07 +02:00
Berker Peksag 1a9f51ed12
bpo-14014: Clarify StreamWriter.reset() documentation (GH-13716) 2021-01-06 04:14:42 +02:00
Erlend Egeberg Aasland ddb5e11683
bpo-24464: Deprecate sqlite3.enable_shared_cache (GH-24008) 2021-01-06 02:36:04 +02:00
Erlend Egeberg Aasland cf0b23908c
bpo-40810: Require SQLite 3.7.15 (GH-24106) 2021-01-06 02:02:43 +02:00
Mark Shannon ee9f98d9f4
bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)
* Add test for frame.f_lineno with/without tracing.

* Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set.

* Update importlib

* Add NEWS
2021-01-05 12:04:10 +00:00
Cheryl Sabella e40e2a2cc9
bpo-32631: IDLE: Enable zzdummy example extension module (GH-14491)
Make menu items work with formatter, add docstrings, add 100% tests.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-01-05 02:26:43 -05:00
Serhiy Storchaka 59f9b4e450
bpo-42681: Fix test_curses failures related to color pairs (GH-24089)
On ncurses 6.1 pair numbers are limited by SHORT_MAX-1, even
with extended color support.

Improve error reporting and tests for color functions.
2021-01-05 09:13:15 +02:00
Brandt Bucher 27f9dafc2b
bpo-40636: Remove overly-strict zip pickling tests (GH-24109) 2021-01-04 23:05:29 -08:00
Erlend Egeberg Aasland f7f0ed59bc
bpo-40810: Fix CheckTraceCallbackContent for SQLite pre 3.7.15 (GH-20530)
Ref. [SQLite 3.7.15 changelog](https://sqlite.org/changes.html#version_3_7_15):
_"Avoid invoking the sqlite3_trace() callback multiple times when a statement is automatically reprepared due to SQLITE_SCHEMA errors."_
2021-01-04 15:16:43 -08:00
Pablo Galindo ef2d371dee Python 3.10.0a4
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEz9yiRbEEPPKl+Xhl/+h0BBaL2EcFAl/zT6kACgkQ/+h0BBaL
 2EeKVhAAxHzHdp1zZyDgqx0yBoHrB/N7aA5aL8dsrRPPIp+vd6CVanCymd2I2W59
 N8ouYoXFDUbDoWW/E26ggnMtbDtN7HUmMV48v9KIeDHVIR+CcSePcT9cWldmZr+m
 9J7aVoU/MswsLbUpLh5XnXYFbPziv2lsaMWz/j/6EX6VpzVuvmS0sg+xYea6/Kg0
 GyE2Le7p5WZ+5He1OJJOPFJ9/yOzj9fix2DDhRP7ZP8Oi+vPlRsDGMO1E3YKQzP1
 4bWhhoSCTDGIW6l0j41xGZYyW7Ror6FqpJqOGygYsA9LwryPdhqQVIVR7sqoK0sC
 xmLF1XrZhipNi+in7XxtmStor9MGVu5oR4Ieawhd70LEOrfdux2I7vTCEz4YqW0K
 7evxZ4fjfKALkAoJZ6WhUHcJf97n08+lyGo5Ng4miBi0VXYaj45l6pdpEPOZKfx1
 flXYThu4VOfZ7ggi4Y/Mxi4U2sQVbNtXD19KhrxsKe+wdfRQ2I/fkYrz/nCA/bJe
 qt7HO9AuyiqbBWQ88ZrnHsZLiuidXiBEQ5Evxb2aDNx+gOTeoa+W02BflRZ2wQN5
 d9+/THh0LE12OARa8DZvYYWRj/IiKLx5YbVkuhMxwBbWpSO4nlq2OKhX5Cdc3hxd
 Pp4j5oZX0Wg283vIwgfZYa3E0TfjSs+bu2euCMsWe/7oFw4ZNKc=
 =3nPI
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEz9yiRbEEPPKl+Xhl/+h0BBaL2EcFAl/zhaAACgkQ/+h0BBaL
 2Ecvow//bxy+jIPxR7IDlnTOxUMBXU/97ed9AozzPUzfov09S5OYP04S1UDC8dqt
 DqLzCBPJrc/+t8t6q2oksfOJGHrPJOQIBDKEST7yxa0k7TbZodJ3QVqHAe2dYF48
 QbACiOphBCXwUBR+Gk6kJxZAPUZelyUxL4ZgZMhFvJD5ONVl3VWeMzodCejYluYM
 Zs6MRMOHvbcaZgrB4M7fn2TS+ZAaFqORsMx/FSzNLmJf+42iTI/ZGICwRFMaiB6V
 Z1A9ajvcm8W37RL1GLAe7fE43WUzmE1QhwGnVv2kRoz5Q5tHJy8Rcp//ZIAUCTXq
 4jCX24T0H7ze/vPEkdX4TYc/3Xzd5vR2WqIyVnNjdM/Ye6ouuHmyf701Ql17qBRU
 fJ3aINJkOnXzmlPMsClrA9VxsBnX7raJHuj3YkCkUZv+jM6oap8IwGCO3uTkGVpa
 SiIuZ/2SmSujT6b67CZrBgmJB30uGzUKiqPZKT2rYgLS8C7PnGg0gaPfrcVIvwxZ
 XRAkDBzlY0mhmj8ss66UJc83faLYI+3ralSoRhR/5F3JLd7bIC/0TUBBTbZP9Jec
 +sxO+RQHG2TbN89mULDqbfsPRTuNIF83s9Zcg2OQG09ClVNEfdUKZ1UgMo+X/nST
 ZShaM3oQ720VN9ZzMJrzglMESs2QT37ERKtehInR1YDBytydD3c=
 =UiJ+
 -----END PGP SIGNATURE-----

Merge tag 'v3.10.0a4'

Python 3.10.0a4
2021-01-04 21:16:13 +00:00
Mark Shannon 127dde5916
bpo-42810: Mark jumps at end of if and try statements as artificial. (GH-24091)
* Mark jumps at end of if and try statements as artificial.

* Update importlib

* Add comment explaining the purpose of ADDOP_JUMP_NOLINE.
2021-01-04 18:06:55 +00:00
Pablo Galindo 445f7f54b1
Python 3.10.0a4 2021-01-04 17:26:00 +00:00
Serhiy Storchaka b6fc0c406e
bpo-42789: Enable using /dev/tty in test_curses. (GH-24085)
It was temporary disabled for debugging.
2021-01-04 12:30:20 +02:00
Serhiy Storchaka 1470edd613
bpo-42681: Fix range checks for color and pair numbers in curses (GH-23874) 2021-01-03 22:51:11 +02:00
Pablo Galindo bd2728b1e8
bpo-42806: Fix ast locations of f-strings inside parentheses (GH-24067) 2021-01-03 01:11:41 +00:00
Lysandros Nikolaou 2ea320dddd
bpo-40631: Disallow single parenthesized star target (GH-24027) 2021-01-03 01:14:21 +02:00
Raymond Hettinger 8f8de7380c
No need to test "istep==1" twice. (GH-24064) 2021-01-02 12:09:56 -08:00
Raymond Hettinger 768fa145cf
bpo-42772: Step argument ignored when stop is None. (GH-24018) 2021-01-02 10:24:51 -08:00
Serhiy Storchaka 607501abb4
bpo-42789: Don't skip curses tests on non-tty. (GH-24009)
If __stdout__ is not attached to terminal, try to use __stderr__
if it is attached to terminal, or open the terminal device, or
use regular file as terminal, but some functions will be untested
in the latter case.
2021-01-02 19:35:15 +02:00
Serhiy Storchaka a25011be8c
bpo-42809: Improve pickle tests for recursive data. (GH-24060) 2021-01-02 19:32:47 +02:00
Ken Jin 49cd68fb1e
bpo-42195: Disallow isinstance/issubclass for subclasses of genericaliases in Union (GH-24059)
Previously this didn't raise an error. Now it will:
```python
from collections.abc import Callable
isinstance(int, list | Callable[..., str])
```
Also added tests in Union since there were previously none for stuff like ``isinstance(list, list | list[int])`` either.

Backport to 3.9 not required.

Automerge-Triggered-By: GH:gvanrossum
2021-01-02 08:19:15 -08:00
Kurochan d9142831ba
handle empty string in variable executable in platform.libc_ver() (#23140) 2021-01-02 17:03:53 +01:00
Ken Jin 11276cd9c4
bpo-41559: Documentation for PEP 612 (GH-24000) 2021-01-01 16:45:50 -08:00
Ross 3bf05327c2
bpo-42756: Configure LMTP Unix-domain socket to use global default timeout when timeout not provided (GH-23969) 2021-01-02 02:20:25 +09:00
Dong-hee Na ec3165320e
bpo-42794: Update test_nntplib to use offical group name for testing (GH-24037) 2021-01-01 23:20:33 +09:00
Jason R. Coombs b5711c940f
bpo-37193: Remove thread objects which finished process its request (GH-23127)
This reverts commit aca67da4fe.
2020-12-31 20:19:30 +00:00
Jason R. Coombs a6fd0f414c
bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (for all but processor) (#23010)
* Add test capturing missed expectation with uname_result._replace.

* bpo-42163: Override uname_result._make to allow uname_result._replace to work (for everything but 'processor'.

* Replace hard-coded length with one derived from the definition.

* Add test capturing missed expectation with copy/deepcopy on namedtuple (bpo-42189).

* bpo-42189: Exclude processor parameter when constructing uname_result.

* In _make, rely on __new__ to strip processor.

* Add blurb.

* iter is not necessary here.

* Rely on num_fields in __new__

* Add test for slices on uname

* Add test for copy and pickle.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

* import pickle

* Fix equality test after pickling.

* Simply rely on __reduce__ for pickling.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-12-31 14:08:03 -05:00
Jason R. Coombs dfdca85dfa
bpo-42382: In importlib.metadata, `EntryPoint` objects now expose `dist` (#23758)
* bpo-42382: In importlib.metadata, `EntryPoint` objects now expose a `.dist` object referencing the `Distribution` when constructed from a `Distribution`.

Also, sync importlib_metadata 3.3:

- Add support for package discovery under package normalization rules.
- The object returned by `metadata()` now has a formally-defined protocol called `PackageMetadata` with declared support for the `.get_all()` method.

* Add blurb

* Remove latent footnote.
2020-12-31 12:56:43 -05:00
Erlend Egeberg Aasland f4936ad1c4
bpo-42393: Raise OverflowError iso. DeprecationWarning on overflow in socket.ntohs and socket.htons (GH-23980) 2020-12-31 15:16:50 +02:00
Brandon Stansbury 9655434cca
bpo-39068: Fix race condition in base64 (GH-17627)
There was a race condition in base64 in lazy initialization of multiple globals.
2020-12-31 11:44:46 +02:00
Yurii Karabas c56387f80c
bpo-27794: Add `name` attribute to `property` class (GH-23967) 2020-12-30 01:51:24 -08:00
Hai Shi dd39123970
bpo-40137: Convert _functools module to use PyType_FromModuleAndSpec. (GH-23405) 2020-12-29 04:45:07 -08:00
Senthil Kumaran 030a713183
Allow / character in username,password fields in _PROXY envvars. (#23973) 2020-12-29 04:18:42 -08:00
Ross c1af128f5a
bpo-41781: Fix typo in internal function name in typing (GH-23957) 2020-12-29 13:55:28 +02:00
Serhiy Storchaka 1df56bc059
bpo-42759: Fix equality comparison of Variable and Font in Tkinter (GH-23968)
Objects which belong to different Tcl interpreters are now always
different, even if they have the same name.
2020-12-29 12:56:55 +02:00
Serhiy Storchaka 156b7f7052
bpo-42749: Use dynamic version to test for unsupported bignum in Tk (GH-23966)
Tk can internally support bignum even if Tkinter is built without
support of bignum.
2020-12-29 12:55:55 +02:00
Ken Jin efb1f0918f
bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin (GH-23942) 2020-12-28 18:26:19 -08:00
Ken Jin 4140f10a16
bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963)
PR 1/2. Needs backport to 3.9.
2020-12-28 12:06:19 -08:00
Raymond Hettinger a9621bb301
bpo-42222: Modernize integer test/conversion in randrange() (#23064) 2020-12-28 11:10:34 -08:00
Serhiy Storchaka b02ad2458b
bpo-42749: Fix testing bignum if Tkinter is compiled with Tk 8.4 and dynamic linked with Tk >= 8.5 (GH-23955) 2020-12-27 10:13:30 +02:00
Pablo Galindo 3bcc4ead3f
Add small validator utility for PEG grammars (GH-23519) 2020-12-26 19:11:29 +00:00
Dong-hee Na 0b281f94b9
bpo-42748: test_asdl_parser now uses exec_module instead of load_module (#23954) 2020-12-26 16:25:21 +03:00
Serhiy Storchaka c1ae21c965
Rename Tkinter tests for widget options (GH-23944)
Every test for widget option starts now with "test_configure_"
to distinguish it from tests for widget commands.
2020-12-26 00:10:29 +02:00
Desmond Cheong 36a779e64c
bpo-35728: Add root parameter to tkinter.font.nametofont() (GH-23885) 2020-12-25 23:18:06 +02:00
Serhiy Storchaka 675c97eb6c
bpo-42721: Improve using simple dialogs without root window (GH-23897)
When simple query dialogs (tkinter.simpledialog), message boxes
(tkinter.messagebox) or color choose dialog (tkinter.colorchooser)
are created without arguments master and parent, and the default
root window is not yet created, a new temporary hidden root window
will be created automatically. It will not be set as the default root
window and will be destroyed right after closing the dialog window.
It will help to use these simple dialog windows in programs which do
not need other GUI.

Previously, message boxes and color chooser created the blank root
window and left it after closing the dialog window, and query dialogs
just raised an exception.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-12-25 20:19:20 +02:00
Irit Katriel 586f3dbe15
bpo-28964: add line number of node (if available) to ast.literal_eval error messages (GH-23677) 2020-12-25 20:04:31 +03:00
Serhiy Storchaka bb70b2afe3
bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904)
Use `widget is None` instead of checking the boolean value of a widget.
2020-12-25 17:04:26 +02:00
Serhiy Storchaka 954a7427ba
bpo-42734: Fix crasher bogus_code_obj.py (GH-23939)
It did not work because the signature of code object constructor
was changed. Also, it used old format of bytecode (pre-wordcode).
2020-12-25 17:03:37 +02:00
Gregory P. Smith 64abf37344
bpo-42388: Fix subprocess.check_output input=None when text=True (GH-23467)
When the modern text= spelling of the universal_newlines= parameter was added
for Python 3.7, check_output's special case around input=None was overlooked.
So it behaved differently with universal_newlines=True vs text=True.  This
reconciles the behavior to be consistent and adds a test to guarantee it.

Also clarifies the existing check_output documentation.

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2020-12-24 20:57:21 -08:00
Ethan Furman 786d97a66c
bpo-42727: [Enum] use super() and include **kwds (GH-23927)
for multiple inheritance support:

use super().new
pass **kwds to super().new
2020-12-24 19:31:10 -08:00
Serhiy Storchaka c6c43b2874
bpo-42685: Improve placing of simple query windows. (GH-23856)
* If parent is specified and mapped, the query widget is
  centered at the center of parent. Its position and size
  can be corrected so that it fits in the virtual root window.
* Otherwise it is centered at the center of the screen.
2020-12-24 20:26:28 +02:00
Ethan Furman 6ec0adefad
[Enum] EnumMeta.__prepare__ now accepts **kwds (#23917) 2020-12-24 10:05:02 -08:00
kj 73607be686
bpo-41559: Implement PEP 612 - Add ParamSpec and Concatenate to typing (#23702) 2020-12-23 20:33:48 -08:00
Raymond Hettinger cc3467a57b
bpo-38308: Add optional weighting to statistics.harmonic_mean() (GH-23914) 2020-12-23 19:52:09 -08:00
kj 6dd3da3cf4
bpo-42195: Override _CallableGenericAlias's __getitem__ (GH-23915)
Added `__getitem__` for `_CallableGenericAlias` so that it returns a subclass (itself) of `types.GenericAlias` rather than the default behavior of returning a plain `types.GenericAlias`. This fixes `repr` issues occuring after `TypeVar` substitution arising from the previous behavior.
2020-12-23 18:47:40 -08:00
Batuhan Taskaya eee1c7745a
bpo-41960: Add globalns and localns parameters to inspect.signature and Signature.from_callable (GH-22583) 2020-12-24 01:45:13 +03:00
Victor Stinner a12491681f
bpo-32381: pymain_run_command() uses PyCF_IGNORE_COOKIE (GH-23724)
The coding cookie (ex: "# coding: latin1") is now ignored in the
command passed to the -c command line option.

Since pymain_run_command() uses UTF-8, pass PyCF_IGNORE_COOKIE
compiler flag to the parser.

pymain_run_python() no longer propages compiler flags between
function calls.
2020-12-23 19:16:56 +01:00
Raymond Hettinger 41b223d29c
bpo-9694: Fix misleading phrase "optional arguments" (GH-23858) 2020-12-23 09:40:56 -08:00
Victor Stinner bfda4f5776
bpo-28468: Fix typo in _os_release_candidates (GH-23913)
Automerge-Triggered-By: GH:tiran
2020-12-23 08:35:53 -08:00
Mark Shannon 28b75c80dc
bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896) 2020-12-23 11:43:10 +00:00
Irit Katriel 069560b117
bpo-34463: Make python tracebacks identical to C tracebacks for SyntaxErrors without a lineno (GH-23427) 2020-12-22 21:53:09 +02:00
AMIR b8fde8b541
bpo-42008: Fix internal _random.Random() seeding for the one argument case (GH-22668) 2020-12-21 15:45:50 -08:00
Fernando Toledo 711381dfb0
Fix typo in docstring (GH-23515) 2020-12-21 16:06:31 +02:00
Mark Shannon f2dbfd7e20
bpo-42634: Mark reraise after except blocks as artificial. (GH-23877)
* Mark reraise after except blocks as artificial.

* Update importlib

* Update dis test.
2020-12-21 13:53:50 +00:00
Daniel Hahler 37a6d5f802
[WIP/RFC] bpo-15872: tests: remove oddity from test_rmtree_errors (GH-22967)
This was added for (some) Windows buildbots back in 2012, and should
either not be necessary anymore, or it should probably get investigated
why "\*.*" gets added to filenames in the first place.

Ref:

Automerge-Triggered-By: GH:hynek
2020-12-20 22:38:02 -08:00
pxinwr ab74c014ae
bpo-31904: Fix site and sysconfig modules for VxWorks RTOS (GH-21821) 2020-12-20 23:27:42 +01:00
Serhiy Storchaka 3d569fd6dc
bpo-42630: Improve error reporting in Tkinter for absent default root (GH-23781)
* Tkinter functions and constructors which need a default root window
  raise now RuntimeError with descriptive message instead of obscure
  AttributeError or NameError if it is not created yet or cannot
  be created automatically.

* Add tests for all functions which use default root window.

* Fix import in the pynche script.
2020-12-19 12:17:08 +02:00
masklinn 1e27b57dbc
bpo-42470: Do not warn on sequences which are also sets in random.sample() (GH-23665) 2020-12-18 20:33:36 -08:00
Raymond Hettinger 51f4688254
bpo-34805: Guarantee that __subclasses__() is in definition order. (GH-23844) 2020-12-18 16:53:50 -08:00
Irit Katriel fb34096140
bpo-24792: Fix zipimporter masking the cause of import errors (GH-22204)
zipimport's _unmarshal_code swallows import errors and then _get_module_code doesn't know the cause of the error, and returns the generic, and sometimes incorrect, 'could not find...'.

Automerge-Triggered-By: GH:brettcannon
2020-12-18 16:09:54 -08:00
Andre Delfino e8d2264210
bpo-36769: Document that fnmatch.filter supports any kind of iterable (#13039) 2020-12-18 20:10:20 +01:00
Richard Kojedzinszky 17ef4319a3
bpo-41891: ensure asyncio.wait_for waits for task completion (#22461) 2020-12-18 09:26:04 -08:00
Max Bernstein 6e799be0a1
bpo-42199: Fix bytecode_helper assertNotInBytecode (#23031)
* bpo-42199: Fix bytecode_helper assertNotInBytecode

Add tests.

* 📜🤖 Added by blurb_it.

Co-authored-by: Dino Viehland <dinoviehland@fb.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2020-12-17 16:30:29 -08:00
pxinwr 75dabfe7a8
bpo-31904: posixpath.expanduser() handles None user home on VxWorks (GH-23530) 2020-12-17 20:22:29 +01:00
Mark Shannon bf353f3c2d
bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly after raising or reraising an exception (GH-23803)
* Ensure that f_lasti is set correctly after an exception is raised to conform to PEP 626.

* Update importlib

* Add NEWS.
2020-12-17 13:55:28 +00:00
pxinwr ba760f3710
bpo-31904: Skip some asyncio tests on VxWorks (#23815) 2020-12-17 12:04:47 +02:00
Mike Lei c143cc379c
Correct referenced RFC number in cgi module (GH-22827)
The quoted sentence can be found from the last paragraph of RFC 2046, Section 5.1, while the content of RFC 2026 is unrelated to this module.
2020-12-16 17:34:19 -08:00
Daniel Hahler 051b981867
bpo-37961: Fix regression in tracemalloc.Traceback.__repr__ (GH-23805)
Regression in 8d59eb1b66.
2020-12-16 22:38:32 +01:00
Chris Jerdonek 66d3b589c4
bpo-38323: Add guard clauses in MultiLoopChildWatcher. (#22756)
This is a trivial refactor in preparation for a fix for bpo-38323.
2020-12-16 19:50:25 +02:00
Mark Shannon 5274b682bc
bpo-42645: Make sure that return/break/continue are only traced once when exiting via a finally block. (GH-23780)
* Make sure that return/break/continue are only traced once when exiting via a finally block.

* Add test for return in try-finally.

* Update importlib
2020-12-16 13:07:01 +00:00
Om G c71581c7a4
bpo-42615: Delete redundant jump instructions that only bypass empty blocks (GH-23733)
* Delete jump instructions that bypass empty blocks

* Add news entry

* Explicitly check for unconditional jump opcodes

Using the is_jump function results in the inclusion of instructions like
returns for which this optimization is not really valid. So, instead
explicitly check that the instruction is an unconditional jump.

* Handle conditional jumps, delete jumps gracefully

* Ensure b_nofallthrough and b_reachable are valid

* Add test for redundant jumps

* Regenerate importlib.h and edit Misc/ACKS

* Fix bad whitespace
2020-12-16 12:18:05 +00:00
Victor Stinner 99d28c5670
bpo-40364: asyncio uses os.waitstatus_to_exitcode() (GH-23798)
test_unix_events.py no longer checks if waitstatus_to_exitcode() mock
has been called or not to make the test more functional, rather than
checking the exact implementation.
2020-12-16 12:11:24 +01:00
Serhiy Storchaka 5f0fe8ec70
bpo-19733: Re-enable tests for -image option in Tkinter (GH-23785) 2020-12-16 12:31:49 +02:00
Victor Stinner 79782fe4f8
bpo-41804: Enhance test_epoll.test_control_and_wait() (GH-23795)
Use shorter timeout and replace send() with sendall().
2020-12-16 11:16:25 +01:00
Matthias Bussonnier b32d8b4f9b
bpo-42644: Validate values in logging.disable() (#23786)
* bpo-42644: Validate values in logging.disable()

Technically make the value of manager a property that checks and convert
values assigned to it properly. This has the side effect of making
`logging.disable` also accept strings representing the various level of
warnings.

We want to validate the type of the disable attribute at assignment
time, as it is later compared to other levels when emitting warnings and
would generate a `TypeError: '>=' not supported between ....` in a
different part of the code base, which can make it difficult to track
down.

When assigned an incorrect value; it will raise a TypeError when the
wrong type, or ValueError if an invalid str.

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2020-12-16 11:43:39 +02:00
Jason R. Coombs 928dbfc16c
bpo-42090: zipfile.Path.joinpath now accepts multiple arguments (GH-22976)
Automerge-Triggered-By: GH:jaraco
2020-12-15 18:12:54 -08:00
pxinwr b230409f21
bpo-31904: Skip os.path.expanduser() tests on VxWorks (GH-23776) 2020-12-15 22:24:00 +01:00
pxinwr 9a0dea6137
bpo-31904: Skip some tests of changing owner in _test_all_chown_common() on VxWorks (GH-23716) 2020-12-15 22:21:53 +01:00
pxinwr e1e3c2dac3
bpo-31904: Disable os.popen and popen test cases on VxWorks (GH-21687) 2020-12-15 22:20:07 +01:00
E-Paine b9ced83cf4
bpo-40219: Lowered ttk LabeledScale dummy (GH-21467) 2020-12-15 21:42:55 +02:00
Victor Stinner 7f14a3756b
bpo-42641: Enhance test_select.test_select() (GH-23782)
Enhance test_select.test_select(): it now takes 500 ms rather than 10
seconds.

* Use Python rather than a shell as the child process to make the
  test more portable.
* Use a sleep of 50 ms per line rather than 1 second.
* Use subprocess.Popen rather than os.popen().
2020-12-15 18:06:36 +01:00
Victor Stinner 3ca2b8fd75
bpo-42639: atexit._run_exitfuncs() uses sys.unraisablehook (GH-23779)
atexit._run_exitfuncs() now logs callback exceptions using
sys.unraisablehook, rather than logging them directly into
sys.stderr and raising the last exception.

Run GeneralTest of test_atexit in a subprocess since it calls
atexit._clear() which clears all atexit callbacks.

_PyAtExit_Fini() sets state->callbacks to NULL.
2020-12-15 17:12:02 +01:00
Victor Stinner f7049b5fb6
bpo-42639: Add script_helper.run_test_script() (GH-23777)
* Add run_test_script() function to test.support.script_helper.
* Rename Lib/test/eintrdata/eintr_tester.py to
  Lib/test/_test_eintr.py.
* test_eintr.py uses run_test_script().
2020-12-15 16:08:16 +01:00
Victor Stinner b8fa135908
bpo-42639: Move atexit state to PyInterpreterState (GH-23763)
* Add _PyAtExit_Call() function and remove pyexitfunc and
  pyexitmodule members of PyInterpreterState. The function
  logs atexit callback errors using _PyErr_WriteUnraisableMsg().
* Add _PyAtExit_Init() and _PyAtExit_Fini() functions.
* Remove traverse, clear and free functions of the atexit module.

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2020-12-15 14:34:19 +01:00
Mark Shannon 8473cf89bd
bpo-42246: Remove DO_NOT_EMIT_BYTECODE macros, so that while loops and if statements conform to PEP 626. (GH-23743) 2020-12-15 11:07:50 +00:00
Terry Jan Reedy 6f79e60b66
bpo-33610: Edit idlelib.codecontext (GH-23773)
Add sentence to module docstring and import tkinter items.
2020-12-15 00:24:01 -05:00
Victor Stinner 357704c9f2
bpo-42639: atexit now logs callbacks exceptions (GH-23771)
At Python exit, if a callback registered with atexit.register()
fails, its exception is now logged. Previously, only some exceptions
were logged, and the last exception was always silently ignored.

Add _PyAtExit_Call() function and remove
PyInterpreterState.atexit_func member. call_py_exitfuncs() now calls
directly _PyAtExit_Call().

The atexit module must now always be built as a built-in module.
2020-12-14 23:07:54 +01:00
Victor Stinner 83d52044ae
bpo-42639: Cleanup atexitmodule.c (GH-23770)
* Rename "atexitmodule_state" to "struct atexit_state".
* Rename "modstate" to "state".
* Rename "self" parameter to "module".
* test_atexit uses textwrap.dedent().
* Remove _Py_PyAtExit() function: inline it into atexit_exec().
* PyInterpreterState: rename pyexitfunc to atexit_func, rename
  pyexitmodule to atexit_module.
2020-12-14 22:40:40 +01:00
vabr-g fdb9efce6a
bpo-41877: Check for misspelled speccing arguments (GH-23737)
patch, patch.object and create_autospec silently ignore misspelled
arguments such as autospect, auto_spec and set_spec. This can lead
to tests failing to check what they are supposed to check.

This change adds a check causing a RuntimeError if the above
functions get any of the above misspellings as arguments. It also
adds a new argument, "unsafe", which can be set to True to disable
this check.

Also add "!r" to format specifiers in added error messages.
2020-12-14 10:30:09 -08:00
Gregory P. Smith 42c9f0fd0a
bpo-36541: Add lib2to3 grammar PEP-570 pos-only arg parsing (GH-23759)
Add positional only args support to lib2to3 pgen2.

This adds 3.8's PEP-570 support to lib2to3's pgen2.  lib2to3, while
being deprecated is still used by things to parse all versions of Python
code today.  We need it to support parsing modern 3.8 and 3.9 constructs.

Also add tests for complex *expr and **expr's.
2020-12-14 09:10:10 -08:00
Mark Shannon f5e97b72fe
bpo-42635: Mark JUMP_ABSOLUTE at end of 'for' loop as artificial to avoid spurious line events. (GH-23761) 2020-12-14 11:28:39 +00:00
Mark Shannon 56aa20f9eb
Don't generate spurious line number in try-except-finally. (#23760) 2020-12-14 10:19:10 +00:00
kj 463c7d3d14
bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and typing (GH-23060) 2020-12-13 10:38:24 -08:00
Pablo Galindo 43c4fb6c90
bpo-30858: Improve error location for expressions with assignments (GH-23753)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2020-12-13 16:46:48 +00:00
Ethan Furman b5a6db9111
bpo-39717: [tarfile] update nested exception raising (GH-23739)
- `from None` if the new exception uses, or doesn't need, the previous one
- `from e` if the previous exception is still relevant
2020-12-12 13:26:44 -08:00
Alex Grönholm 67b769f515
bpo-42059: Fix required/optional keys for TypedDict(..., total=False) (GH-22736) 2020-12-10 13:49:05 -08:00
Ethan Furman a658287179
bpo-34750: [Enum] add `_EnumDict.update()` support (GH-23725)
This allows easier Enum construction in unusual cases, such as including dynamic member definitions into a class definition:

# created dynamically
foo_defines = {'FOO_CAT': 'aloof', 'BAR_DOG': 'friendly', 'FOO_HORSE': 'big'}

class Foo(Enum):
    vars().update({
            k: v
            for k, v in foo_defines.items()
            if k.startswith('FOO_')
            })
    def upper(self):
        # example method
        return self.value.upper()
2020-12-10 13:07:00 -08:00
Ethan Furman efb13be72c
bpo-42385: [Enum] add `_generate_next_value_` to StrEnum (GH-23735)
The default for auto() is to return an integer, which doesn't work for `StrEnum`.  The new `_generate_next_value_` for `StrEnum` returns the member name, lower cased.
2020-12-10 12:20:06 -08:00
vabr-g 9fc571359a
bpo-41877: Improve docs for assert misspellings check in mock (GH-23729)
This is a follow-up to
4662fa9bfe.
That original commit expanded guards against misspelling assertions on
mocks. This follow-up updates the documentation and improves the error
message by pointing out the potential cause and solution.

Automerge-Triggered-By: GH:gpshead
2020-12-10 10:35:28 -08:00
Ethan Furman 7cf0aad96d
bpo-42517: [Enum] do not convert private names into members (GH-23722)
private names, such as `_Color__hue` and `_Color__hue_` are now normal attributes, and do not become members nor raise exceptions
2020-12-09 17:12:11 -08:00
Ethan Furman 6bd94de168
bpo-42567: [Enum] call __init_subclass__ after members are added (GH-23714)
When creating an Enum, type.__new__ calls __init_subclass__, but at that point the members have not been added.

This patch suppresses the initial call, then manually calls the ancestor __init_subclass__ before returning the new Enum class.
2020-12-09 16:41:22 -08:00
pxinwr 98a5417193
bpo-41439: Skip test_ssl and test_uuid tests if fork() is not supported (GH-21684) 2020-12-09 00:20:19 +01:00
pxinwr eb7594f857
bpo-41443: Add more attribute checking in test_posix (GH-21688) 2020-12-09 00:18:37 +01:00
Ethan Furman 6d3dfee271
[Enum] reformat and add doc strings (GH-23705) 2020-12-08 12:26:56 -08:00
Ethan Furman 37440eef7f
bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497) 2020-12-08 11:14:10 -08:00
Petr Viktorin c168b5078f
bpo-42111: Make the xxlimited module an example of best extension module practices (GH-23226)
- Copy existing xxlimited to xxlimited53 (named for the limited API version it uses)
- Build both modules, both in debug and release
- Test both modules
2020-12-08 08:36:53 -08:00
Pablo Galindo 8bae2a958e
Python 3.10.0a3 2020-12-07 19:34:10 +00:00
Matti Picus c0afb7fa0e
bpo-39825: Fixes sysconfig.get_config_var('EXT_SUFFIX') on Windows to match distutils (GH-22088) 2020-12-07 17:33:20 +00:00
Ethan Furman c266736ec1
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487) 2020-12-07 00:17:31 -08:00
Terry Jan Reedy 57e5113610
bpo-42508: Keep IDLE running on macOS (GH-23577)
Remove obsolete workaround that prevented running files with
shortcuts when using new universal2 installers built on macOS 11.
Ignore buggy 2nd run_module_event call.
2020-12-06 22:22:33 -05:00
Serhiy Storchaka 8a62887dfb
bpo-42582: Remove asyncio._all_tasks_compat(). (GH-23664)
It was used to implement now removed asyncio.Task.all_tasks().
2020-12-06 18:54:33 +02:00