Commit Graph

28743 Commits

Author SHA1 Message Date
Victor Stinner 1735710873
gh-77782: Py_FdIsInteractive() now uses PyConfig.interactive (#93916) 2022-06-17 15:19:28 +02:00
Victor Stinner c5b750dc0b
gh-93852: Add test.support.create_unix_domain_name() (#93914)
test_asyncio, test_logging, test_socket and test_socketserver now
create AF_UNIX domains in the current directory to no longer fail
with OSError("AF_UNIX path too long") if the temporary directory (the
TMPDIR environment variable) is too long.

Modify the following tests to use create_unix_domain_name():

* test_asyncio
* test_logging
* test_socket
* test_socketserver

test_asyncio.utils: remove unused time import.
2022-06-17 13:16:51 +02:00
neonene ffc228dd4e
gh-89745: Avoid exact match when comparing program_name in test_embed on Windows (GH-93888) 2022-06-17 11:06:49 +01:00
Gregory P. Smith 4beee0c7b0
gh-91404: Revert "bpo-23689: re module, fix memory leak when a match is terminated by a signal or allocation failure (GH-32283) (#93882)
Revert "bpo-23689: re module, fix memory leak when a match is terminated by a signal or memory allocation failure (GH-32283)"

This reverts commit 6e3eee5c11.

Manual fixups to increase the MAGIC number and to handle conflicts with
a couple of changes that landed after that.

Thanks for reviews by Ma Lin and Serhiy Storchaka.
2022-06-17 01:19:44 -07:00
Victor Stinner 538f28921f
test_logging: Fix BytesWarning in SysLogHandlerTest (GH-93920) 2022-06-17 09:09:54 +01:00
Irit Katriel e37a158725
GH-83658: make multiprocessing.Pool raise an exception if maxtasksperchild is not None or a positive int (GH-93364)
Closes #83658.
2022-06-17 00:14:26 -07:00
neonene 38af903506
gh-91985: Ensure in-tree builds override platstdlib_dir in every path calculation (GH-93641) 2022-06-16 22:41:57 +01:00
Brandt Bucher f8e576be0a
GH-91389: Fix dis position information for CACHEs (GH-93663) 2022-06-16 13:49:32 -07:00
Victor Stinner 4f85cec9e2
gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
2022-06-16 21:48:26 +02:00
Serhiy Storchaka 138db8e48b
gh-93847: Fix repr of enum of generic aliases (GH-93885) 2022-06-16 12:16:12 -07:00
Victor Stinner a38c2a61d5
gh-91321: Fix test_cppext for C++03 (#93902)
Don't build _testcppext.cpp with -Wzero-as-null-pointer-constant when
testing C++03: only use this compiler flag with C++11.
2022-06-16 14:39:00 +02:00
Victor Stinner 484b40bf18
Call busy_retry() and sleeping_retry() with error=True (#93871)
Tests no longer call busy_retry() and sleeping_retry() with
error=False: raise an exception if the loop times out.
2022-06-16 13:44:58 +02:00
Christian Heimes 05b32c1c79
gh-93820: Fix copy() regression in enum.Flag (GH-93876)
GH-26658 introduced a regression in copy / pickle protocol for combined
`enum.Flag`s. `copy.copy(re.A | re.I)` would fail with
`AttributeError: ASCII|IGNORECASE`.

`enum.Flag` now has a `__reduce_ex__()` method that reduces flags by
combined value, not by combined name.
2022-06-15 23:42:36 -07:00
Victor Stinner 50e0866f87
Tests call sleeping_retry() with SHORT_TIMEOUT (#93870)
Tests now call busy_retry() and sleeping_retry() with SHORT_TIMEOUT
or LONG_TIMEOUT (of test.support), rather than hardcoded constants.

Add also WAIT_ACTIVE_CHILDREN_TIMEOUT constant to
_test_multiprocessing.
2022-06-15 18:49:14 +02:00
Victor Stinner 46e455f21c
test_asyncore: Optimize capture_server() (#93867)
Remove time.sleep(0.01) in test_asyncore capture_server(). The sleep
was redundant and inefficient, since the loop starts with
select.select() which also implements a sleep (poll for socket data
with a timeout).
2022-06-15 18:28:31 +02:00
Victor Stinner 41fccd23e9
test_asyncio: run_until() implements exponential sleep (#93866)
run_until() of test.test_asyncio.utils now uses an exponential sleep
delay (max: 1 second), rather than a fixed delay of 1 ms. Similar
design than support.sleeping_retry() wait strategy that applies
exponential backoff.
2022-06-15 18:28:00 +02:00
Kumar Aditya b415c5f1aa
GH-93850: Fix test_asyncio exception ignored tracebacks (#93854) 2022-06-15 16:41:47 +02:00
Victor Stinner 0ba80273f2
Use support.sleeping_retry() and support.busy_retry() (#93848)
* Replace time.sleep(0.010) with sleeping_retry() to
  use an exponential sleep.
* support.wait_process(): reuse sleeping_retry().
* _test_eintr: remove unused variables.
2022-06-15 14:09:56 +02:00
Victor Stinner bddbd80cff
test_thread uses support.sleeping_retry() (#93849)
test_thread.test_count() now fails if it takes longer than
LONG_TIMEOUT seconds.
2022-06-15 13:52:13 +02:00
Victor Stinner 7e9eaad864
Add test.support.busy_retry() (#93770)
Add busy_retry() and sleeping_retry() functions to test.support.
2022-06-15 11:42:10 +02:00
Jeong YunWon 274769c61c
gh-93814: Add infinite test for itertools.chain.from_iterable (GH-93815)
fix #93814

Automerge-Triggered-By: GH:rhettinger
2022-06-14 13:45:50 -07:00
Victor Stinner 36934a16e8
gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813) 2022-06-14 18:04:53 +02:00
Erlend Egeberg Aasland d773c6e95a
gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (#93796) 2022-06-14 16:02:52 +02:00
Erlend Egeberg Aasland 46740073ef
gh-79579: Improve DML query detection in sqlite3 (#93623)
The fix involves using pysqlite_check_remaining_sql(), not only to check
for multiple statements, but now also to strip leading comments and
whitespace from SQL statements, so we can improve DML query detection.

pysqlite_check_remaining_sql() is renamed lstrip_sql(), to more
accurately reflect its function, and hardened to handle more SQL comment
corner cases.
2022-06-14 13:56:36 +02:00
Victor Stinner e566ce5496
gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
2022-06-14 13:43:02 +02:00
Ken Jin b083450f88
GH-93429: Merge `LOAD_METHOD` back into `LOAD_ATTR` (GH-93430) 2022-06-14 11:36:22 +01:00
Mark Shannon 2bf74753c1
GH-93662: Make sure that column offsets are correct in multi-line method calls. (GH-93673) 2022-06-14 11:08:12 +01:00
Victor Stinner 4caf5c2753
gh-91321: Fix compatibility with C++ older than C++11 (#93784)
Fix the compatibility of the Python C API with C++ older than C++11.

_Py_NULL is only defined as nullptr on C++11 and newer.
2022-06-14 11:43:08 +02:00
Vinay Sajip 5bcf33de0b
gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779) 2022-06-14 06:41:16 +01:00
Serhiy Storchaka d7db9dc3cc
gh-91810: Fix regression with writing an XML declaration with encoding='unicode' (GH-93426)
Suppress writing an XML declaration in open files in ElementTree.write()
with encoding='unicode' and xml_declaration=None.

If file patch is passed to ElementTree.write() with encoding='unicode',
always open a new file in UTF-8.
2022-06-14 07:25:33 +03:00
Serhiy Storchaka 8352e322e8
gh-79512: Fixed names and __module__ value of weakref classes (GH-93719)
Classes ReferenceType, ProxyType and CallableProxyType have now correct
atrtributes __module__, __name__ and __qualname__.
It makes them (types, not instances) pickleable.
2022-06-14 07:18:03 +03:00
Victor Stinner 7b2064b4b9
gh-93353: Add test.support.late_deletion() (#93774) 2022-06-14 01:09:23 +02:00
Christian Heimes c2007573dd
gh-84461: Fix parallel testing on WebAssembly (GH-93768) 2022-06-13 19:51:04 +02:00
Victor Stinner 3ceb4b8d3a
gh-84623: Remove unused imports in tests (#93772) 2022-06-13 16:56:03 +02:00
Serhiy Storchaka 3473817106
gh-91162: Support splitting of unpacked arbitrary-length tuple over TypeVar and TypeVarTuple parameters (alt) (GH-93412)
For example:

  A[T, *Ts][*tuple[int, ...]] -> A[int, *tuple[int, ...]]
  A[*Ts, T][*tuple[int, ...]] -> A[*tuple[int, ...], int]
2022-06-12 16:22:01 +03:00
Christian Heimes f0b7aa71c4
gh-90473: Skip test_queue when threading is not available (GH-93712) 2022-06-11 11:55:11 +02:00
Dennis Sweeney 4c496f1f11
gh-92930: _pickle.c: Acquire strong references before calling save() (GH-92931) 2022-06-10 21:50:11 -04:00
jackh-ncl 484a2357c8
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_zipimport.py` (GH-93236) 2022-06-10 15:57:04 -07:00
Christian Heimes 09243b898a
gh-93461: Invalidate sys.path_importer_cache entries with relative paths (GH-93653) 2022-06-10 23:56:26 +02:00
Irit Katriel cf730b595e
GH-93621: reorder code in with/async-with exception exit path to reduce the size of the exception table (GH-93622) 2022-06-10 17:53:34 +01:00
Barney Gale 2ba0fd5767
gh-81790: support "UNC" device paths in `ntpath.splitdrive()` (GH-91882) 2022-06-10 16:59:55 +01:00
Pablo Galindo Salgado 53a8b17895
gh-93671: Avoid exponential backtracking in deeply nested sequence patterns in match statements (GH-93680)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-10 17:56:45 +02:00
Petr Viktorin 21a9a85ff4
gh-93466: Document PyType_Spec doesn't accept repeated slot IDs; raise where this was problematic (GH-93471) 2022-06-10 15:55:09 +02:00
Leo Trol 30610d2837
gh-90549: Fix leak of global named resources using multiprocessing spawn (#30617)
Co-authored-by: XD Trol <milestonejxd@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2022-06-09 18:55:12 +02:00
Christian Heimes 6099611af5
gh-90473: Skip get_config_h() tests on WASI (GH-93645) 2022-06-09 18:08:03 +02:00
Serhiy Storchaka a365dd64c2
gh-90494: Reject 6th element of the __reduce__() tuple (GH-93609)
copy.copy() and copy.deepcopy() now always raise a TypeError if
__reduce__() returns a tuple with length 6 instead of silently ignore
the 6th item or produce incorrect result.
2022-06-09 10:12:43 +03:00
Christian Heimes cffa4f7854
gh-93616: Fix env changed issue in test_modulefinder (GH-93617) 2022-06-09 08:32:35 +02:00
Christian Heimes 68f6a5da19
gh-79096: Fix/improve http cookiejar tests (GH-93614)
Fixup of GH-93463:
- remove stray print
- use proper way to check file mode
- add working chmod decorator

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-08 23:51:04 +02:00
Christian Heimes 5442561c1a
gh-93575: Use correct way to calculate PyUnicode struct sizes (GH-93602)
* gh-93575: Use correct way to calculate PyUnicode struct sizes

* Add comment to keep test_sys and test_unicode in sync

* Fix case code < 256
2022-06-08 20:18:08 +02:00
Erlend Egeberg Aasland 875de61c29
gh-93421: Update sqlite3 cursor.rowcount only after SQLITE_DONE (#93526) 2022-06-08 12:43:54 +02:00
Bluenix 5849af7a80
GH-93521: For dataclasses, filter out `__weakref__` slot if present in bases (GH-93535) 2022-06-07 20:53:08 -04:00
Kalyan ffc58a9710
gh-93370: Deprecate sqlite3.version and sqlite3.version_info (#93482)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-06-08 01:34:50 +02:00
Irit Katriel f8eae6f5c3
GH-93481: Suppress expected deprecation warning in test_pyclbr (GH-93483) 2022-06-07 21:35:11 +01:00
Adrian Garcia Badaracco 296081a7ce
gh-92592: Allow logging filters to return a LogRecord. (GH-92591) 2022-06-07 16:53:57 +01:00
Christian Heimes cdb73aefec
gh-93162: test_config_queue_handler requires threading (GH-93572) 2022-06-07 12:34:08 +02:00
Mark Shannon f012df706c
Shrink the LOAD_METHOD cache by one codeunit. (#93537) 2022-06-07 10:28:53 +01:00
Hugo van Kemenade f0d0be3493
gh-57539: Increase calendar test coverage (GH-93468)
Co-authored-by: Sean Fleming
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-07 10:44:29 +02:00
Vinay Sajip 1b74803991
gh-93162: Add ability to configure QueueHandler/QueueListener together (GH-93269)
Also, provide getHandlerByName() and getHandlerNames() APIs.

Closes #93162.
2022-06-07 10:20:35 +02:00
Pascal Wittmann c6f6ede728
gh-79096: Protect cookie file created by {LWP,Mozilla}CookieJar.save() (GH-93463)
Note: This change is not effective on Microsoft Windows.

Cookies can store sensitive information and should therefore be protected
against unauthorized third parties. This is also described in issue #79096.

The filesystem permissions are currently set to 644, everyone can read the
file. This commit changes the permissions to 600, only the creater of the file
can read and modify it. This improves security, because it reduces the attack
surface. Now the attacker needs control of the user that created the cookie or
a ways to circumvent the filesystems permissions.

This change is backwards incompatible. Systems that rely on world-readable
cookies will breake. However, one could argue that those are misconfigured in
the first place.
2022-06-07 10:11:03 +02:00
AN Long 3256b178ed
bpo-42658: Use LCMapStringEx in ntpath.normcase to match OS behaviour for case-folding (GH-32010) 2022-06-07 00:47:27 +01:00
Christian Heimes 22fed605e0
gh-90473: Make chmod a dummy on WASI, skip chmod tests (GH-93534)
WASI does not have the ``chmod(2)`` syscall yet.
2022-06-06 19:24:11 +02:00
Christian Heimes 80a39daecd
gh-90473: Skip POSIX tests that don't apply to WASI (GH-93536) 2022-06-06 16:31:59 +02:00
Christian Heimes 4c71d22c4f
gh-90473: WASI requires proper open(2) flags (GH-93529) 2022-06-06 12:08:07 +02:00
Cyker Way 9081bbd036
gh-93247: Fix assert function in asyncio locks test (#93248) 2022-06-05 18:19:18 -07:00
Serhiy Storchaka 0902c3d8ed
gh-89973: Fix re.error in the fnmatch module. (GH-93072)
Character ranges with upper bound less that lower bound (e.g. [c-a])
are now interpreted as empty ranges, for compatibility with other glob
pattern implementations. Previously it was re.error.
2022-06-05 11:46:29 +03:00
Christian Heimes 6f8367d348
gh-90473: wasmtime does not support absolute symlinks (GH-93490) 2022-06-05 09:59:47 +02:00
Neil Schemenauer 713eb184b5
gh-93442: Add test for _Py_CAST(nullptr). (gh-93505) 2022-06-05 12:53:16 +09:00
Neil Schemenauer 8bcc3fa345
gh-93442: Make C++ version of _Py_CAST work with 0/NULL. (#93500)
Add C++ overloads for _Py_CAST_impl() to handle 0/NULL.  This will allow
C++ extensions that pass 0 or NULL to macros using _Py_CAST() to
continue to compile.  Without this, you get an error like:

    invalid ‘static_cast’ from type ‘int’ to type ‘_object*’

The modern way to use a NULL value in C++ is to use nullptr.  However,
we want to not break extensions that do things the old way.

Co-authored-by: serge-sans-paille
2022-06-04 18:49:39 -07:00
jackh-ncl 8150b8cf7f
gh-92886: Fix test that fails when running with `-O` in `test_imaplib.py` (#93237) 2022-06-03 20:15:58 -07:00
Barney Gale f32e6b48d1
gh-93156 - fix negative indexing into absolute `pathlib.PurePath().parents` (GH-93273)
When a `_PathParents` object has a drive or a root, the length of the
object is *one less* than than the length of `self._parts`, which resulted
in an off-by-one error when `path.parents[-n]` was fed through to
`self._parts[:-n - 1]`. In particular, `path.parents[-1]` was a malformed
path object with spooky properties.

This is addressed by adding `len(self)` to negative indices.
2022-06-03 14:33:20 -07:00
Christian Heimes 1a8a0ddb1c
gh-84461: Skip dtrace/network tests that are enabled by -u all (GH-93473) 2022-06-03 22:14:31 +02:00
Victor Stinner d8f40ead92
test.pythoninfo: Fix typo, Py_REF_DEBUG => Py_TRACE_REFS (#93467) 2022-06-03 15:46:41 +02:00
Petr Viktorin b9509ba7a9
gh-68966: Make mailcap refuse to match unsafe filenames/types/params (GH-91993) 2022-06-03 11:43:35 +02:00
Dong-hee Na b013804134
gh-92932: dis._unpack_opargs should handle EXTENDED_ARG_QUICK (gh-92945) 2022-06-03 11:29:27 +09:00
Christian Heimes 069c96f84c
gh-90473: Skip and document more failing tests on WASI (GH-93436)
- Mark more ``umask()`` cases
- ``dup()`` is not supported
- ``/dev/null`` is not available
- document missing features
- mark more modules as not available
2022-06-03 00:44:48 +02:00
Irit Katriel 94b1586ca5
gh-93356: Lay out exception handling code at end of code unit (GH-92769) 2022-06-02 14:13:43 +01:00
Christian Heimes af5bb1fba4
gh-84461: Skip new async logging tests on Emscripten (GH-93427) 2022-06-02 09:35:06 +02:00
Eric V. Smith ee70c70aa9
gh-93418: Fix an assert when an f-string expression is followed by an '=', but no closing brace. (gh-93419) 2022-06-01 19:20:06 -04:00
Éric 8aa9d40b00
gh-90300: split --help output into separate options (#30331)
Make --help output shorter and add new help options.

--help-env, --help-xoptions and --help-all command-line options are
added to complement --help.
2022-06-01 05:50:01 -04:00
Ezio Melotti 5247389369
Remove the execution bit to some socket-related files. (#93368) 2022-06-01 09:11:46 +02:00
Pablo Galindo Salgado 705eaec28f
gh-92597: Ensure that AST nodes without explicit end positions can be compiled (GH-93359) 2022-06-01 00:00:47 +01:00
Dennis Sweeney f425f3bb27
gh-93143: Avoid NULL check in LOAD_FAST based on analysis in the compiler (GH-93144) 2022-05-31 16:32:30 -04:00
Serhiy Storchaka 07df8d5b2c
gh-93283: Improve error message for f-string with invalid conversion character (GH-93349) 2022-05-31 20:38:29 +03:00
Serhiy Storchaka f545fc955a
gh-93345: Fix a crash in substitution of nested TypeVar after TypeVarTuple (GH-93346)
For example: tuple[*Ts, list[T]][int, str, bool]
2022-05-31 08:46:16 +03:00
Pablo Galindo Salgado 5893b5db98
gh-93351: Ensure the position information in AST nodes created by the parser is always consistent (GH-93352) 2022-05-30 19:30:15 +01:00
Sergei Izmailov 66f5add1f0
bpo-41287: Handle `doc` argument of `property.__init__` in subclasses (#23205)
Fixes #85459

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-28 20:25:51 -07:00
oda-gitso 7fa9b7daa5
gh-92839: fixed typo in _bisectmodule.c (line 131) (#92849) 2022-05-28 13:08:06 -05:00
Ethan Furman 70cfe56caf
gh-93250: [Enum] Change IntEnum boundary to KEEP for backwards compatibility (GH-93302)
In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type.  This change restores that behavior.
2022-05-27 15:14:28 -07:00
hfinucane 47e68d4515
bpo-46951: Order contents of zipapps (GH-31713)
So that builds are more reproducible.
2022-05-27 19:04:29 +03:00
Dennis Sweeney ddc4a782d3
gh-93223: More aggressive Jump-To-Jump elimination (GH-93229) 2022-05-27 11:17:59 +01:00
Wenzel Jakob 5e34b494a0
gh-60074: add new stable API function PyType_FromMetaclass (GH-93012)
Added a new stable API function ``PyType_FromMetaclass``, which mirrors
the behavior of ``PyType_FromModuleAndSpec`` except that it takes an
additional metaclass argument. This is, e.g., useful for language
binding tools that need to store additional information in the type
object.
2022-05-27 10:27:39 +02:00
Victor Stinner 20d30ba2cc
gh-92898: Enhance _testcppext test on cast to PyObject* (#93111)
* Add StrongRef class.
* Rename and reformat functions of the _Py_CAST() implementation.
2022-05-27 01:12:39 +02:00
Vinay Sajip efc5d37671
gh-91513: Tidied up a test and did minor refactoring around test filename gener… (GH-93265) 2022-05-26 17:11:15 +01:00
Victor Stinner 06dd26f89f
test.pythoninfo logs more build info (#93225)
Log also test.support.check_sanitizer() values.
2022-05-26 16:07:01 +02:00
jackh-ncl cc377063ef
gh-91513: Add 'asyncio' taskName to logging LogRecord attributes. (GH-93193) 2022-05-26 09:30:51 +01:00
Victor Stinner 5185956527
gh-69443: Add test.support.Py_DEBUG constant (#93226) 2022-05-26 00:12:54 +02:00
Steve Dower ca58e4a2c5
gh-93005: Fix py.exe launcher test to search for intended tag (GH-93190) 2022-05-25 22:59:33 +01:00
Akuli a4974003ec
gh-93124: Fix typos in comments (GH-93125)
Fixes #93124

Automerge-Triggered-By: GH:rhettinger
2022-05-25 08:34:14 -07:00
Christian Heimes 1f134e96ba
gh-90473: Misc test fixes for WASI (GH-93218)
* ``sys.executable`` is not set
* WASI does not support subprocess
* ``pwd`` module is not available
* WASI checks ``open`` syscall flags more strict, needs r, w, rw flag.
* ``umask`` is not available
* ``/dev/null`` may not be accessible
2022-05-25 15:57:26 +02:00
Erlend Egeberg Aasland db3ef0c82a
gh-93117: Remove too large sqlite3 bigmemtest (#93154) 2022-05-25 14:53:26 +02:00
Florian Bruhin 19710145b4
test_threaded_import: Fix unittest.main spelling (GH-93114) 2022-05-25 10:59:32 +03:00
Miro Hrončok 16a7e4a0b7
gh-92728: Restore re.template, but deprecate it (GH-93161)
Revert "bpo-47211: Remove function re.template() and flag re.TEMPLATE (GH-32300)"

This reverts commit b09184bf05.
2022-05-25 09:05:35 +03:00
Victor Stinner 4a31ed8a32
test.pythoninfo no longer requires socket (#93191)
test.pythoninfo no longer fails if "import socket" fails: the socket
module is now optional.
2022-05-25 02:11:51 +02:00
Jordan Borean fbd11f3edd
gh-92658: Add Hyper-V socket support (GH-92755) 2022-05-24 21:37:06 +01:00
Kumar Aditya d2ef66a10b
GH-89369: test_contextlib_async finalizes event loop after each test (#93074)
Use asyncio.run().
2022-05-24 15:41:32 +02:00
Florian Bruhin 37c9a351b1
GH-93112: Fix missing ResourceDenied import in test_urllib2net (#93113)
The code was moved out of test.support in
311110abcd (GH-20812), thus making
ResourceDenied undefined.
2022-05-24 14:09:52 +02:00
Dong-hee Na f7fabae75c
gh-93099: Fix _pyio to use locale module properly (gh-93136) 2022-05-24 09:37:01 +09:00
Yury Selivanov c1f5c903a7
gh-93065: Fix HAMT to iterate correctly over 7-level deep trees (GH-93066)
Also while there, clarify a few things about why we reduce the hash to 32 bits.

Co-authored-by: Eli Libman <eli@hyro.ai>
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-05-23 21:09:59 +02:00
Sam Ezeh 202ed2506c
gh-83245: Raise BadZipFile instead of ValueError when reading a corrupt ZIP file (GH-32291)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-23 20:59:21 +03:00
oda-gitso 71abeb0895
gh-93010: InvalidHeaderError used but nonexistent (#93015)
* fix issue 93010

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-05-23 09:10:18 -07:00
Steve Dower 949dbf97ba
gh-93005: Fixes launcher test when no Python install is available (GH-93007) 2022-05-23 17:04:26 +01:00
Florian Bruhin d5f0dd1600
GH-93115: Fix version check in sqlite3 module constants test (#93116) 2022-05-23 17:58:11 +02:00
Ethan Furman 046df59658
gh93107: [Enum] fix missing variable in global_str (GH-93107) 2022-05-23 08:56:07 -07:00
Dennis Sweeney a458be3263
gh-93061: Mark as artificial: backwards jump after async for (GH-93062) 2022-05-23 13:58:41 +01:00
Christian Heimes 760ec8940a
gh-90473: WASI: skip gethostname tests (GH-93092)
- WASI's ``gethostname()`` is a stub that always fails with OSError
  ``ENOTSUP``
- skip mailcap ``test`` if subprocess is not available
- WASI process_time clock does not work.
2022-05-23 10:39:57 +02:00
Mori Bellamy 9bc616cb4c
gh-91061: also accept pathlib.Path for winsound.PlaySound (#91489)
Fixes #91061

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-22 18:54:24 -07:00
Serhiy Storchaka e5d8dbdd30
Clean up the sqlite3 tests (GH-93056)
Remove helper managed_connect(). Use memory_database() or
contextlib.closing() + addCleanup(unlink) instead.
2022-05-21 19:06:12 +03:00
Serhiy Storchaka 4e2b664892
Improve tests for opening Sqlite by URI (GH-93047)
* Test with with escaped non-ascii characters
* Test read-only open of existing DB.
2022-05-21 17:38:22 +03:00
serge-sans-paille 5b71b519f9
GH-92898: Make _Py_Cast C++ version compatible with cast operator (gh-92951) 2022-05-21 22:16:37 +09:00
Serhiy Storchaka 14c0d33016
gh-93044: No longer convert the database argument of sqlite3.connect() to bytes (GH-93046)
Just pass it to the factory as is.
2022-05-21 14:35:46 +03:00
Serhiy Storchaka d853758092
gh-91922: Fix sqlite connection on nonstardard locales and paths (GH-92926) 2022-05-20 11:53:05 +03:00
Steve Dower 73473fdeac
gh-92817: Fix precedence of options to py.exe launcher (GH-92988) 2022-05-19 23:45:41 +01:00
Steve Dower 403d16fa28
gh-92913: Clarify changes to PyInitConfig.module_search_paths[_set] fields (GH-92980) 2022-05-19 20:23:53 +01:00
Nikita Sobolev 8db2b3b687
bpo-28249: fix `lineno` location for empty `DocTest` instances (GH-30498)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-05-19 17:46:15 +02:00
David Foster 30deeac649
gh-92675: venv: Fix ensure_directories() to again accept a Path for env_dir (#92676)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-19 07:47:16 -07:00
Christian Heimes 137fd3d88a
gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803) 2022-05-19 12:43:16 +02:00
Mark Shannon e48ac9c100
GH-90690: Remove `PRECALL` instruction (GH-92925) 2022-05-19 11:05:26 +01:00
Ayappan Perumal 654032ac5f
gh-92670: Skip test_shutil.TestCopy.test_copyfile_nonexistent_dir on AIX (#92718) 2022-05-19 11:17:44 +02:00
Serhiy Storchaka 8a6af5a346
gh-92914: Round the allocated size for lists up to the even number (GH-92915) 2022-05-19 08:43:50 +03:00
Victor Stinner 970efae274
gh-89898: Fix test_threading.test_args_argument() (#92885)
Join the thread to not leak threads running in the background to the
next test.

Fix the following warning on the "AMD64 FreeBSD Shared 3.11"
buildbot:

test_args_argument (test.test_threading.ThreadTests.test_args_argument) ...
Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 2)
Warning -- Dangling thread: <_MainThread(MainThread, started 35026161664)>
Warning -- Dangling thread: <Thread(Thread-134 (<lambda>), started 35314998016)>
ok
2022-05-18 00:19:56 +02:00
Victor Stinner e6fd7992a9
gh-89653: PEP 670: Fix PyUnicode_READ() cast (#92872)
_Py_CAST() cannot be used with a constant type: use _Py_STATIC_CAST()
instead.
2022-05-17 19:20:37 +02:00
Dennis Sweeney 19a4252459
gh-92536: Update unicode struct size to ensure MemoryError is raised (GH-92867) 2022-05-17 10:12:21 -04:00
Filipe Laíns c7d699969c
gh-92265: set meta_path and path_hooks correctly in test_reload_namespace_changed (GH-92275)
Previously, we were blocking the frozen imports and forcing the source
version to be used, but we did not fix up sys.meta_path or
sys.path_hooks, causing the frozen importers to leak into the source
version of the test.
2022-05-16 16:05:47 -07:00
Erlend Egeberg Aasland 00f22e8cc2
gh-92547: Remove deprecated sqlite3 features (#92548)
The following sqlite3 features were deprecated in 3.10, scheduled for
removal in 3.12:

- sqlite3.OptimizedUnicode (gh-23163)
- sqlite3.enable_shared_cache (gh-24008)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Signed-off-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-05-16 19:52:08 +02:00
Christian Heimes 9b50585e02
gh-90473: Skip tests that don't apply to Emscripten and WASI (GH-92846) 2022-05-16 16:02:37 +02:00
Batuhan Taskaya f6fd8aac13
gh-92671: Don't omit parentheses when unparsing empty tuples (GH-92673) 2022-05-16 13:38:06 +01:00
Victor Stinner ca0cc9c433
gh-92820: Skip test_cppext if _ctypes is missing (#92844)
Add @test.support.requires_venv_with_pip decorator.
2022-05-16 13:54:45 +02:00
Christian Heimes 730902c0ad
gh-90473: WASI: Mark tests that require os.pipe() (GH-92837) 2022-05-16 09:37:30 +02:00
Mark Shannon 22a1db378c
GH-92236: Remove spurious "line" event when starting coroutine or generator. (GH-92722) 2022-05-13 11:24:45 +01:00
Christian Heimes d81d57e959
gh-90473: Increase stack size, disable obmalloc on WASI (GH-92732) 2022-05-13 08:36:01 +02:00
Victor Stinner 4e28377722
gh-92584: test_cppext uses setuptools (#92639)
Rewrite test_cppext to run in a virtual environment and to build the
C++ extension with setuptools rather than distutils.
2022-05-13 00:20:13 +02:00
Dennis Sweeney 8cf2906828
gh-92311: Add tests for frame_setlineno jumping over listcomps (#92741) 2022-05-12 17:43:54 -04:00
Paul Ganssle 83c0247d47
Check result of utc_to_seconds and skip fold probe in pure Python (#91582)
The `utc_to_seconds` call can fail, here's a minimal reproducer on
Linux:

TZ=UTC python -c "from datetime import *; datetime.fromtimestamp(253402300799 + 1)"

The old behavior still raised an error in a similar way, but only
because subsequent calculations happened to fail as well. Better to fail
fast.

This also refactors the tests to split out the `fromtimestamp` and
`utcfromtimestamp` tests, and to get us closer to the actual desired
limits of the functions. As part of this, we also changed the way we
detect platforms where the same limits don't necessarily apply (e.g.
Windows).

As part of refactoring the tests to hit this condition explicitly (even
though the user-facing behvior doesn't change in any way we plan to
guarantee), I noticed that there was a difference in the places that
`datetime.utcfromtimestamp` fails in the C and pure Python versions, which
was fixed by skipping the "probe for fold" logic for UTC specifically —
since UTC doesn't have any folds or gaps, we were never going to find a
fold value anyway. This should prevent some failures in the pure python
`utcfromtimestamp` method on timestamps close to 0001-01-01.

There are two separate news entries for this because one is a
potentially user-facing change, the other is an internal code
correctness change that, if anything, changes some error messages. The
two happen to be coupled because of the test refactoring, but they are
probably best thought of as independent changes.

Fixes GH-91581
2022-05-12 17:00:50 -04:00
ravi140222 079f0dd719
gh-91578: improved error message when trying to instantiate an abstract class with missing methods (gh-47246) 2022-05-12 11:26:11 -04:00
Jelle Zijlstra 8a0d9a6bb7
gh-92514: Remove unused test.support.BasicTestRunner (#92515) 2022-05-12 07:24:04 -07:00
Inada Naoki f9c9354a7a
gh-92536: PEP 623: Remove wstr and legacy APIs from Unicode (GH-92537) 2022-05-12 14:48:38 +09:00
Raymond Hettinger 68fec31364
gh-86388 Remove deprecated behaviors in randrange() (#92677) 2022-05-11 23:54:51 -05:00
Dennis Sweeney 27185f98ff
gh-92031, test_embed: Improve test for unquickening static code (#92440) 2022-05-12 00:54:00 +02:00
Victor Stinner 1d1929fcb5
gh-90978: asyncio TestSSL uses SHORT_TIMEOUT (#92642)
TestSSL of asyncio now uses support.SHORT_TIMEOUT rather than
hardcoded timeouts like 5, 10 or 40 seconds.
2022-05-11 23:25:56 +02:00
Serhiy Storchaka 707839b0fe
gh-91810: ElementTree: Use text file's encoding by default in XML declaration (GH-91903)
ElementTree method write() and function tostring() now use the text file's
encoding ("UTF-8" if not available) instead of locale encoding in XML
declaration when encoding="unicode" is specified.
2022-05-11 09:31:07 +03:00
Serhiy Storchaka 87f849c775
gh-92550: Fix pathlib.Path.rglob() for empty pattern (GH-92604) 2022-05-11 07:43:04 +03:00
Serhiy Storchaka b1c4368824
Revert "gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)" (GH-92598)
This reverts commit dcdf250d2d.
2022-05-11 07:14:25 +03:00
Bar Harel 30a43586f0
bpo-39264: Fix UserDict.get() to account for __missing__() (GH-17910)
Here's the patch according to the discussion at the [Python-Dev mailing list](https://mail.python.org/archives/list/python-dev@python.org/thread/SDXOEMAEM6KQ3CQCJVBVRT5QNSPAVU6X/).
UserDict.get() will match dict's behavior and not call `__missing__`.

Automerge-Triggered-By: GH:rhettinger
2022-05-10 14:23:45 -07:00
Gregory P. Smith 07b34926d3
gh-84131: Remove the deprecated pathlib.Path.link_to method. (#92505)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
2022-05-10 12:31:41 -07:00
Irit Katriel 7c6b7ade8d
gh-92619: Fix bug where the compiler duplicates exit blocks unnecessarily (GH-92620) 2022-05-10 13:36:08 +01:00
Barney Gale dcdf250d2d
gh-92550 - Fix regression in `pathlib.Path.rglob()` (GH-92583)
We could try to remedy this by taking a slice, but we then run into an issue where the empty string will match altsep on POSIX. That rabbit hole could keep getting deeper.

A proper fix for the original issue involves making pathlib's path normalisation more configurable - in this case we want to retain trailing slashes, but in other we might want to preserve `./` prefixes, or elide `../` segments when we're sure we won't encounter symlinks.

This reverts commit ea2f5bcda1.
2022-05-09 17:12:16 -07:00
Gregory P. Smith 6ed7c353b8
gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509)
Remove the `PYTHONTHREADDEBUG` env var support.
Remove no-op dprintf() macro calls.
2022-05-09 16:03:46 -07:00
Raymond Hettinger e01eeb7b4b
Fix inconsistent return type for statistics median_grouped() gh-92531 (#92533) 2022-05-09 02:08:41 -05:00
Gregory P. Smith ebb37fc3fd
gh-90622: Do not spawn ProcessPool workers on demand via fork method. (#91598)
Do not spawn ProcessPool workers on demand when they spawn via fork.

This avoids potential deadlocks in the child processes due to forking from
a multithreaded process.
2022-05-08 09:20:34 -07:00
Serhiy Storchaka a84a56d80f
gh-91760: More strict rules for numerical group references and group names in RE (GH-91792)
Only sequence of ASCII digits is now accepted as a numerical reference.
The group name in bytes patterns and replacement strings can now only
contain ASCII letters and digits and underscore.
2022-05-08 19:19:29 +03:00
Serhiy Storchaka 9d25db9db1
gh-91162: Fix substitution of unpacked tuples in generic aliases (GH-92335) 2022-05-08 18:32:32 +03:00
Serhiy Storchaka 086c6b1b0f
bpo-45046: Support context managers in unittest (GH-28045)
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
2022-05-08 17:49:09 +03:00
Marc Mueller 5ed5c56123
Add __class_getitem__ to csv.DictReader and csv.DictWriter (#92393) 2022-05-08 07:24:54 -07:00
Serhiy Storchaka 3680ebed7f
bpo-44712: Replace "type(literal)" with corresponding builtin types (GH-27294)
I suppose it is a remnants of very old code written when str, int, list, dict, etc
were functions and not classes.
2022-05-08 17:10:11 +03:00
Matthew Rahtz 4739997e14
gh-92261: Disallow iteration of Union (and other special forms) (GH-92262) 2022-05-08 16:21:28 +03:00
Dong-hee Na d284e8b3e3
Update CPyhton configuration for 3.12 (#92451)
* Update CPyhton configuration for 3.12

* Fix PC/pyconfig.h

* Add expect failure
2022-05-08 13:44:12 +01:00
larryhastings 5021064390
gh-92203: Add closure support to exec(). (#92204)
Add a closure keyword-only parameter to exec(). It can only be specified when exec-ing a code object that uses free variables. When specified, it must be a tuple, with exactly the number of cell variables referenced by the code object. closure has a default value of None, and it must be None if the code object doesn't refer to any free variables.
2022-05-06 10:09:35 -07:00
Victor Stinner 973a5203c1
gh-90978: test_ssl of test_asyncio uses LONG_TIMEOUT (#92402)
On slow buildbot workers, some test_ssl tests fail randomly because
of short timeout (30 seconds). Use support.LONG_TIMEOUT instead which
is longer and also adjusted (by regrtest --timeout option) on
buildbot workers known to be slow.
2022-05-06 15:18:56 +01:00
Brandt Bucher 93a666b5a5
gh-90997: Show cached inline values in `dis` output (#92360) 2022-05-06 15:18:09 +01:00
Serhiy Storchaka 15dbe8570f
gh-91827: Add method info_pathlevel() in tkinter (GH-91829) 2022-05-06 13:50:38 +03:00
Christian Heimes cbc2c199a0
gh-84461: Skip network require tests on Emscripten (GH-92383) 2022-05-06 12:08:36 +02:00
Ethan Furman 93364f9716
gh-78157: [Enum] nested classes will not be members in 3.13 (GH-92366)
- add member() and nonmember() functions
- add deprecation warning for internal classes in enums not
  becoming members in 3.13

Co-authored-by: edwardcwang
2022-05-06 00:16:22 -07:00
Gregory P. Smith fa4f0a134e
gh-90622: Prevent max_tasks_per_child use with a fork mp_context. (#91587)
Prevent `max_tasks_per_child` use with a "fork" mp_context to avoid deadlocks.

Also defaults to "spawn" when no mp_context is supplied for safe convenience.
2022-05-06 00:04:53 -07:00
Alexey Izbyshev 85354ed78c
gh-92112: Fix crash triggered by an evil custom `mro()` (#92113) 2022-05-05 21:01:15 -07:00
Victor Stinner 329afe78c3
gh-57684: Update tests for PYTHONSAFEPATH=1 (#92358)
Fix tests failing with the PYTHONSAFEPATH=1 env var.

Enhance also -P help in Python usage (python --help).
2022-05-06 03:41:24 +02:00
Paul Ganssle 1303f8c927
gh-80010: Expand fromisoformat to include most of ISO-8601 (#92177)
This expands `fromisoformat` to cover most of the common uses of ISO 8601. We may expand the scope more in the future.
2022-05-05 18:31:24 -06:00
Victor Stinner ada8b6d1b1
gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)
Add the -P command line option and the PYTHONSAFEPATH environment
variable to not prepend a potentially unsafe path to sys.path.

* Add sys.flags.safe_path flag.
* Add PyConfig.safe_path member.
* Programs/_bootstrap_python.c uses config.safe_path=0.
* Update subprocess._optim_args_from_interpreter_flags() to handle
  the -P command line option.
* Modules/getpath.py sets safe_path to 1 if a "._pth" file is
  present.
2022-05-06 01:34:11 +02:00
Gregory P. Smith f6dd14c653
gh-82616: Add process_group support to subprocess.Popen (#23930)
One more thing that can help prevent people from using `preexec_fn`.

Also adds conditional skips to two tests exposing ASAN flakiness on the Ubuntu 20.04 Address Sanitizer Github CI system. When that build is run on more modern systems the "problem" does not show up. It seems ASAN implementation related.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-05 16:22:32 -07:00
Christian Heimes 49fda0cc51
gh-70363: Emscripten cannot fstat renamed spool file (GH-92354) 2022-05-06 01:10:37 +02:00
Christian Heimes bb35d6504a
gh-92135: test_cppext requires subprocess (GH-92349) 2022-05-06 00:08:43 +02:00
Christian Heimes c0012df0f6
gh-64783: Don't check value of SIG_DFL and SIG_IGN (#92350) 2022-05-06 00:07:53 +02:00
Serhiy Storchaka 1ed8d035f1
gh-87390: Fix starred tuple equality and pickling (GH-92337) 2022-05-05 20:16:06 +03:00
Irit Katriel e65e587f93
gh-92118: Add test for traceback when exception is modified by (Async)ExitStack.__exit__ (GH-92339) 2022-05-05 17:39:33 +01:00
Vlad Hoi 42fee931d0
bpo-43827: Make arguments to abc.ABCMeta.__new__ pos-only (#25385)
To avoid conflicts with `__init__subclass__`.
2022-05-05 06:40:01 -07:00
Géry Ogam a95138b2c5
bpo-43857: Improve the AttributeError message when deleting a missing attribute (#25424)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-05 06:37:26 -07:00
Raymond Hettinger 5212cbc261
Clean-up and simplify median_grouped(). Vastly improve its docstring. (#92324) 2022-05-05 03:01:07 -05:00
Michael J. Sullivan a918589578
bpo-46764: Fix wrapping bound method with @classmethod (#31367) 2022-05-04 23:00:21 -05:00
Irit Katriel e61330b44f
gh-92118: fix traceback of exceptions propagated from inside a contextlib.contextmanager (GH-92202) 2022-05-04 19:40:47 +01:00
Mark Shannon f8a2fab212
GH-92239: Make sure that PEP 523 is supported, even when specializing first. (GH-92245) 2022-05-04 09:31:21 -06:00
Serhiy Storchaka 9d20e1af40
gh-92107: Add tests that subscription works on arbitrary named tuple types (GH-92304) 2022-05-04 17:06:50 +03:00
Erlend Egeberg Aasland 090819ec5f
gh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572)
* Map SQLITE_MISUSE to sqlite3.InterfaceError

SQLITE_MISUSE implies misuse of the SQLite C API, which, if it happens,
is _not_ a user error; it is an sqlite3 extension module error.

* Raise better errors when binding parameters fail.

Instead of always raising InterfaceError, guessing what went wrong,
raise accurate exceptions with more accurate error messages.
2022-05-04 07:16:01 -06:00
Sam Denton 465fdc02a3
gh-67248: cmd: Sort miscellaneous help topics (#92254)
Closes #67248
2022-05-03 21:36:52 -06:00
Erlend Egeberg Aasland f629dcfe83
gh-80254: Disallow recursive usage of cursors in `sqlite3` converters (#29054)
Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 17:03:06 -06:00
Kumar Aditya e8d7661ff2
GH-91173: disable frozen modules in debug builds (#92023) 2022-05-03 15:20:13 -07:00
Kabir Kwatra 48c6165c28
gh-91928: Add `datetime.UTC` alias for `datetime.timezone.utc` (GH-91973)
### fixes #91928

`UTC` is now module attribute aliased to `datetime.timezone.utc`.
You can now do the following:
```python
from datetime import UTC
```
2022-05-03 15:14:25 -07:00
kixorz 6dee69577a
bpo-45639: Add webp and avif image formats to mimetypes (#29259)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 15:17:57 -06:00
Zac Hatfield-Dodds 65f88a6ef7
gh-92062: `inspect.Parameter` checks whether `name` is a keyword (GH-92065)
Fixes #92062.
2022-05-03 13:52:30 -07:00
Victor Stinner 551d02b3e6
gh-91321: Add _Py_NULL macro (#92253)
Fix C++ compiler warnings: "zero as null pointer constant"
(clang -Wzero-as-null-pointer-constant).

* Add the _Py_NULL macro used by static inline functions to use
  nullptr in C++.
* Replace NULL with nullptr in _testcppext.cpp.
2022-05-03 21:38:37 +02:00
Thaddeus1499 f03d3dd9af
gh-90172: add test for functools.singledispatch on Union types with None type (#92174)
Signed-off-by: prwatson <prwatson@redhat.com>

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 13:17:43 -06:00
Victor Stinner ff3e9cdf33
gh-91320: Fix more old-style cast warnings in C++ (#92247)
Use _Py_CAST(), _Py_STATIC_CAST() and _PyASCIIObject_CAST() in
static inline functions to fix C++ compiler warnings:
"use of old-style cast" (clang -Wold-style-cast).

test_cppext now builds the C++ test extension with -Wold-style-cast.
2022-05-03 20:47:29 +02:00
Victor Stinner b270b82f11
gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
2022-05-03 20:25:41 +02:00
Humbled Drugman b295a92c50
bpo-29890: Test IPv*Interface construction with tuple argument (#30862)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 11:21:24 -06:00
Abhigyan Bose 77e7a04cd2
GH-91752: Skip test_freeze_simple_script when zlib is not available (#91758)
Fixes GH-91752.
2022-05-03 10:19:54 -07:00
Toshio Kuratomi 20490d5018
gh-88753: Make BooleanOptionalAction's addition of default to help more similar to other actions (#27808)
Help for other actions omit the default value if default is SUPPRESS or
already contains the special format string '%(default)'.  Add those
special cases to BooleanOptionalAction's help formatting too.

Fixes https://bugs.python.org/issue44587 so that default=SUPPRESS is not
emitted.

Fixes https://bugs.python.org/issue38956 as this code will detect
whether '%(default)s' has already been specified in the help string.

Signed-off-by: Micky Yun Chan (michiboo): <chanmickyyun@gmail.com>
Co-authored-by: Micky Yun Chan <michan@redhat.com>
2022-05-03 18:38:18 +02:00
Dennis Sweeney b156578bd6
gh-92031: Deoptimize Static Code at Finalization (GH-92039) 2022-05-03 08:59:12 -06:00
Samodya Abey f6f36cc269
bpo-44863: Allow generic typing.TypedDict (#27663)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-03 07:21:42 -06:00
Carey Metcalfe 78e70be331
gh-70363: Implement `io.IOBase` interface for `SpooledTemporaryFile` (GH-29560)
Since the underlying file-like objects (either `io.BytesIO`,
or a true file object) all implement the `io.IOBase`
interface, the `SpooledTemporaryFile` should as well.

Additionally, since the underlying file object will either be an
instance of an `io.BufferedIOBase` (for binary mode) or an
`io.TextIOBase` (for text mode), methods for these classes were also
implemented.

In every case, the required methods and properties are simply delegated
to the underlying file object.

Co-authored-by: Gary Fernie <Gary.Fernie@skyscanner.net>
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
2022-05-03 21:18:18 +09:00
Thomas Cellerier 52dc9c3066
bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (#30642)
`IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of
(address description, netmask) as the address parameter.
When the tuple-based address is used errors are not propagated
correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments:

	In [7]: ipaddress.ip_network(("192.168.100.0", "fooo"))
        ...
	TypeError: not all arguments converted during string formatting

Compared to:

	In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo"))
        ...
	NetmaskValueError: 'foo' is not a valid netmask

Use an f-string to make sure the error is always properly formatted.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 06:12:58 -06:00
Hugo van Kemenade 9b027d4cea
gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) 2022-05-03 10:17:54 +03:00
Ruben Vorderman a73fc73ff7
bpo-46267: Test compresslevel in gzip.compress (#30416)
Fixes #90425
2022-05-02 23:11:06 -06:00
Itai Steinherz 39e6b8ae6a
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858) 2022-05-03 00:19:13 +01:00
Shantanu ebb8b512e9
gh-91621: Fix typing.get_type_hints for collections.abc.Callable (#91656)
This mirrors logic in typing.get_args. The trickiness comes from how we
flatten args in collections.abc.Callable, see
https://bugs.python.org/issue42195
2022-05-02 17:08:28 -06:00
Ethan Smith aff8c4f488
gh-84461: Add ability for multiprocessed libregrtest to use a different Python executable (GH-91930) 2022-05-02 15:51:34 -07:00
Serhiy Storchaka b04e02c57f
bpo-43923: Add support for generic typing.NamedTuple (#92027) 2022-05-02 16:41:23 -06:00
Serhiy Storchaka 81fb3548be
gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176) 2022-05-02 16:38:39 -06:00
kbeldan 4bed9c47bd
gh-92032: Add soft keywords to rlcompleter (#92029)
Let the interpreter autocomplete soft-keywords, ATM the PEP-634 'match'
/ 'case' / '_' (wildcard pattern).

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-05-02 16:36:29 -06:00
Jelle Zijlstra ff88f7e007
gh-87390: Add __unpacked__ attribute to types.GenericAlias (#92059) 2022-05-02 13:21:59 -06:00
Hugo van Kemenade 56f9844014
gh-90765: configparser test: Catch deprecation warning (#91480) 2022-05-02 11:22:26 -06:00
Mark Dickinson 0ed91a26fe
gh-90213: Speed up right shifts of negative integers (GH-30277) 2022-05-02 11:19:03 -06:00
Eric V. Smith 5f9c0f5ddf
Add weakref_slot to dataclass decorator, to allow instances with slots to be weakref-able. (#92160) 2022-05-02 10:36:39 -06:00
Irit Katriel 84b986ba10
gh-91276: revert the increase of dis output width (GH-92126) 2022-05-02 16:51:17 +01:00
Alex Waygood ab616d323d
gh-92128: Add `__class_getitem__` to `logging.LoggerAdapter` and `logging.StreamHandler` (#92129)
Closes #92128
2022-05-02 09:10:02 -06:00
Victor Stinner 031397063e
gh-92135: Fix _Py_reinterpret_cast() for const (#92138)
Fix C++ compiler warnings on cast macros, like _PyObject_CAST(), when
casting a constant expression to a non constant type: use
const_cast<> in C++.

* In C++, Py_SAFE_DOWNCAST() now uses static_cast<> rather than
  reinterpret_cast<>.
* Add tests to the _testcppext C++ extension.
* test_cppext no longer captures stdout in verbose mode.
2022-05-02 17:07:00 +02:00
Erlend Egeberg Aasland 721aa96540
gh-89301: Fix regression with bound values in traced SQLite statements (#92053) 2022-05-02 08:14:35 -06:00
Victor Stinner 79886e7b62
gh-91321: Add _testcppext C++ extension (#32175)
Build a basic C++ test extension to check that the Python C API is
compatible with C++ and does not emit C++ compiler warnings.

* Add Modules/_testcppext.cpp: C++ extension
* Add Lib/test/test_cppext.py: test building the C++ extension.
2022-05-02 14:09:22 +02:00
Serhiy Storchaka 18b07d773e
bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593)
If the error handler returns position less or equal than the starting
position of non-encodable characters, most of built-in encoders didn't
properly re-size the output buffer. This led to out-of-bounds writes,
and segfaults.
2022-05-02 12:37:48 +03:00
Serhiy Storchaka 4d10f703d7
gh-92114: Improve error message for types with __class_getitem__ = None (GH-92115) 2022-05-02 08:29:49 +03:00
Antony Lee ad5e8520f3
bpo-39716: Raise on conflicting subparser names. (GH-18605)
Raise an ArgumentError when the same subparser name is added twice to an
ArgumentParser.  This is consistent with the (default) behavior when the
same option string is added twice to an ArgumentParser.

(Support for `conflict_handler="resolve"` could be considered as a
followup feature, although real use cases seem even rarer than
"resolve"ing option-strings.)

Automerge-Triggered-By: GH:rhettinger
2022-04-30 23:04:50 -07:00
Dennis Sweeney b9636180b3
gh-91954: Use shell=True in test_subprocess.test_encoding_warning (GH-92090) 2022-04-30 20:38:19 -04:00
Dennis Sweeney 868b1afa05
gh-92063: Enforce types in specialized PRECALL opcodes (GH-92068)
* Check the types of PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS as well

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_O

* fix PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST
2022-04-30 12:35:33 -06:00
Erlend Egeberg Aasland 9ea9078ec7
gh-92019: Make sqlite3.Blob indexing conform with the norm (#92020)
- get index now returns an int
- set index now requires an int in range(0, 256)

Resolves #92019
2022-04-30 09:01:37 -06:00
Serhiy Storchaka e91dee87ed
bpo-43323: Fix UnicodeEncodeError in the email module (GH-32137)
It was raised if the charset itself contains characters not encodable
in UTF-8 (in particular \udcxx characters representing non-decodable
bytes in the source).
2022-04-30 13:17:23 +03:00
Serhiy Storchaka 3483299a24
gh-81548: Deprecate octal escape sequences with value larger than 0o377 (GH-91668) 2022-04-30 13:16:27 +03:00
Serhiy Storchaka 19dca04121
gh-91760: Deprecate group names and numbers which will be invalid in future (GH-91794)
Only sequence of ASCII digits will be accepted as a numerical reference.
The group name in bytes patterns and replacement strings could only
contain ASCII letters and digits and underscore.
2022-04-30 13:13:46 +03:00
Inada Naoki 354ace8b07
gh-91954: Emit EncodingWarning from locale and subprocess (GH-91977)
locale.getpreferredencoding() and subprocess.Popen() emit EncodingWarning
2022-04-30 15:53:29 +09:00
Serhiy Storchaka e8c2f72b94
bpo-43224: Implement substitution of unpacked TypeVarTuple in C (GH-31828)
Co-authored-by: Matthew Rahtz <mrahtz@gmail.com>
2022-04-30 08:22:46 +03:00
Dennis Sweeney a29aa76a3f
gh-92064: Fix global variable name collision in test_typing (#92067)
Fixes #92064
2022-04-29 21:18:38 -06:00
Brett Cannon c2b579741d
gh-91217: deprecate xdrlib (GH-92066)
Automerge-Triggered-By: GH:brettcannon
2022-04-29 18:22:10 -07:00
Serhiy Storchaka 81120b6754
bpo-44791: Accept ellipsis as the last argument of typing.Concatenate (#30969) 2022-04-29 15:01:40 -06:00
Matthew Rahtz f6656163de
gh-87390: Add tests demonstrating current type variable substitution behaviour (#32341) 2022-04-29 14:03:21 -06:00
Petr Viktorin 83bce8ef14
gh-91324: Convert the stable ABI manifest to TOML (GH-92026) 2022-04-29 16:18:08 +02:00
Eisuke Kawashima ea2f5bcda1
bpo-22276: Change pathlib.Path.glob not to ignore trailing path separator (GH-10349)
Now pathlib.Path.glob() **only** matches directories when the pattern ends in a path separator.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-28 12:45:03 -07:00
Yurii Karabas 0ef8d921f5
gh-91603: Speed up isinstance/issubclass on union types (GH-91631)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-04-28 23:24:19 +08:00
Abhigyan Bose 4ed3900041
gh-91832: Add 'required' attr to argparse.Action repr (GH-91841)
# Adding 'required' to names in Lib.argparse.Action

gh-91832: 
Added 'required' to the list `names` in `Lib.argparse.Action`. 
Changed constant strings that test the Action object.

Automerge-Triggered-By: GH:merwok
2022-04-28 07:50:27 -07:00
Petr Viktorin 6dcbc08c95
gh-91324: List feature macros in the stable ABI manifest, improve tests (GH-32415) 2022-04-28 16:30:28 +02:00
Abhigyan Bose 88dd227959
gh-91984: Fix trailing spaces in multiline test strings in test_argparse (GH-91986) 2022-04-28 14:29:24 +03:00
Dennis Sweeney 37c6db60f9
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945) 2022-04-27 22:36:34 -06:00
Brett Cannon 407c3afe19
gh-91217: deprecate uu (GH-92009)
Automerge-Triggered-By: GH:brettcannon
2022-04-27 20:26:33 -07:00
Serhiy Storchaka 43a8bf1ea4
gh-87999: Change warning type for numeric literal followed by keyword (GH-91980)
The warning emitted by the Python parser for a numeric literal
immediately followed by keyword has been changed from deprecation
warning to syntax warning.
2022-04-27 20:15:14 +03:00
Serhiy Storchaka f60b4c3d74
gh-91810: Expand ElementTree.write() tests to use non-ASCII data (GH-91989) 2022-04-27 19:16:20 +03:00