Commit Graph

30415 Commits

Author SHA1 Message Date
Serhiy Storchaka b9831e5c98
Use unittest test runner for doctests in test_statistics (GH-108921) 2023-09-07 23:08:55 +03:00
Serhiy Storchaka 7e1a7abb98
gh-68403: Fix test_coverage in test_trace (GH-108910)
Its behavior no longer affected by test running options such as -m.
2023-09-07 21:28:18 +03:00
Ee Durbin 1829a3c9a3
gh-75743: Restore test_timeout.testConnectTimeout() (#109087)
This un-skips this test now that pythontest.net implements appropriate firewall
rules for it.
2023-09-07 20:13:32 +02:00
Serhiy Storchaka f9f085c326
gh-103186: Make test_generated_cases less noisy by default (GH-109100)
Print additional details only when tests are run with -vv.
2023-09-07 20:53:38 +03:00
Irit Katriel 96396962ce
gh-109094: remove unnecessary updates of frame->prev_instr in instrumentation functions (#109076) 2023-09-07 18:23:11 +01:00
Carl Meyer f2584eade3
gh-108732: include comprehension locals in frame.f_locals (#109026)
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-07 08:56:43 -06:00
Serhiy Storchaka b2729e93e9
gh-88943: Improve syntax error for non-ASCII character that follows a numerical literal (GH-109081)
It now points on the invalid non-ASCII character, not on the valid numerical literal.
2023-09-07 17:00:13 +03:00
Mark Shannon 0858328ca2
GH-108614: Add `RESUME_CHECK` instruction (GH-108630) 2023-09-07 14:39:03 +01:00
Serhiy Storchaka d485551c9d
gh-103186: Suppress RuntimeWarning about unclosed async iterator in test_sys_settrace (GH-109075) 2023-09-07 16:34:44 +03:00
Serhiy Storchaka e4bb0026b9
gh-103186: Remove debug print in test_sys_settrace (GH-109077) 2023-09-07 16:30:41 +03:00
Ijtaba Hussain 3e53ac9903
gh-103186: Suppress and assert expected RuntimeWarnings in test_sys_settrace (GH-103244)
Caused as a result of frame manipulation where locals are never assigned / initialised.
2023-09-07 10:41:38 +03:00
Victor Stinner babdced23f
test.pythoninfo logs freedesktop_os_release() (#109057) 2023-09-07 05:43:32 +00:00
Anders Kaseorg f42edf1e7b
gh-109045: Remove remaining LIMITED_API_AVAILABLE checks in tests (#109046)
Commit 13a00078b8 (#108663) made all
Python builds compatible with the Limited API, and removed the
LIMITED_API_AVAILABLE flag.  However, some tests were still checking
for that flag, so they were now being incorrectly skipped.  Remove
these checks to let these tests run again.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2023-09-07 04:42:58 +02:00
Dong-hee Na 3bfa24e29f
gh-107265: Remove all ENTER_EXECUTOR when execute _Py_Instrument (gh-108539) 2023-09-07 09:53:54 +09:00
Victor Stinner a52a350977
gh-109015: Add test.support.socket_helper.tcp_blackhole() (#109016)
Skip test_asyncio, test_imaplib and test_socket tests if FreeBSD TCP
blackhole is enabled (net.inet.tcp.blackhole=2).
2023-09-07 01:58:03 +02:00
Serhiy Storchaka 6f3c138dfa
gh-108751: Add copy.replace() function (GH-108752)
It creates a modified copy of an object by calling the object's
__replace__() method.

It is a generalization of dataclasses.replace(), named tuple's _replace()
method and replace() methods in various classes, and supports all these
stdlib classes.
2023-09-06 23:55:42 +03:00
Serhiy Storchaka 3a08db8d13
gh-106307: Fix PyMapping_GetOptionalItemString() (GH-108797)
The resulting pointer was not set to NULL if the creation of a temporary
string object was failed.

The tests were also missed due to oversight.
2023-09-06 19:47:38 +00:00
Victor Stinner a0773b89df
gh-108753: Enhance pystats (#108754)
Statistics gathering is now off by default. Use the "-X pystats"
command line option or set the new PYTHONSTATS environment variable
to 1 to turn statistics gathering on at Python startup.

Statistics are no longer dumped at exit if statistics gathering was
off or statistics have been cleared.

Changes:

* Add PYTHONSTATS environment variable.
* sys._stats_dump() now returns False if statistics are not dumped
  because they are all equal to zero.
* Add PyConfig._pystats member.
* Add tests on sys functions and on setting PyConfig._pystats to 1.
* Add Include/cpython/pystats.h and Include/internal/pycore_pystats.h
  header files.
* Rename '_py_stats' variable to '_Py_stats'.
* Exclude Include/cpython/pystats.h from the Py_LIMITED_API.
* Move pystats.h include from object.h to Python.h.
* Add _Py_StatsOn() and _Py_StatsOff() functions. Remove
  '_py_stats_struct' variable from the API: make it static in
  specialize.c.
* Document API in Include/pystats.h and Include/cpython/pystats.h.
* Complete pystats documentation in Doc/using/configure.rst.
* Don't write "all zeros" stats: if _stats_off() and _stats_clear()
  or _stats_dump() were called.
* _PyEval_Fini() now always call _Py_PrintSpecializationStats() which
  does nothing if stats are all zeros.

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2023-09-06 15:54:59 +00:00
Victor Stinner 8ff1142578
gh-108851: Fix tomllib recursion tests (#108853)
* Add get_recursion_available() and get_recursion_depth() functions
  to the test.support module.
* Change infinite_recursion() default max_depth from 75 to 100.
* Fix test_tomllib recursion tests for WASI buildbots: reduce the
  recursion limit and compute the maximum nested array/dict depending
  on the current available recursion limit.
* test.pythoninfo logs sys.getrecursionlimit().
* Enhance test_sys tests on sys.getrecursionlimit()
  and sys.setrecursionlimit().
2023-09-06 17:34:31 +02:00
Victor Stinner fbce43a251
gh-91960: Skip test_gdb if gdb cannot retrive Python frames (#108999)
Skip test_gdb if gdb is unable to retrieve Python frame objects: if a
frame is "<optimized out>". When Python is built with "clang -Og",
gdb can fail to retrive the 'frame' parameter of
_PyEval_EvalFrameDefault(). In this case, tests like py_bt() are
likely to fail. Without getting access to Python frames,
python-gdb.py is mostly clueless on retrieving the Python traceback.
Moreover, test_gdb is no longer skipped on macOS if Python is built
with Clang.
2023-09-06 14:34:35 +00:00
Victor Stinner a8cae4071c
gh-107219: Fix concurrent.futures terminate_broken() (#108974)
Fix a race condition in _ExecutorManagerThread.terminate_broken():
ignore the InvalidStateError on future.set_exception(). It can happen
if the future is cancelled before the caller.

Moreover, test_crash_big_data() now waits explicitly until the
executor completes.
2023-09-06 15:57:01 +02:00
Victor Stinner 14d6e197cc
gh-108303: Create Lib/test/test_dataclasses/ directory (#108978)
Move test_dataclasses.py and its "dataclass_*.py" modules into the
new Lib/test/test_dataclasses/ subdirectory.
2023-09-06 15:54:16 +02:00
Nikita Sobolev 1fb20d42c5
gh-108983: Add more PEP 526 tests to `test_grammar` (#108984) 2023-09-06 06:41:38 -07:00
Matthias Bussonnier 5f3433f210
gh-106670: Fix Pdb handling of chained Exceptions with no stacks. (#108865) 2023-09-06 09:41:56 +00:00
Victor Stinner cd2ef21b07
gh-108962: Skip test_tempfile.test_flags() if not supported (#108964)
Skip test_tempfile.test_flags() if chflags() fails with "OSError:
[Errno 45] Operation not supported" (ex: on FreeBSD 13).
2023-09-05 21:59:40 +00:00
Guido van Rossum b87263be9b
gh-106581: Support multiple uops pushing new values (#108895)
Also avoid the need for the awkward .clone() call in the argument
to mgr.adjust_inverse() and mgr.adjust().
2023-09-05 13:58:39 -07:00
Anthony Shaw 2c4c26c4ce
gh-108469: Update ast.unparse for unescaped quote support from PEP701 [3.12] (#108553)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2023-09-05 21:01:23 +01:00
Nikita Sobolev 3f89b25763
gh-108927: Fix test_import + test_importlib + test_unittest problem (#108929) 2023-09-05 18:57:48 +00:00
Serhiy Storchaka 1e0d62793a
gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480) 2023-09-05 17:56:30 +03:00
Serhiy Storchaka f980cc19b9
gh-89392: Use unittest test runner for doctests in test_getopt (GH-108916) 2023-09-05 17:35:28 +03:00
Serhiy Storchaka eaabaac7c0
gh-89392: Use normal unittest runner in test_type_cache (GH-108911) 2023-09-05 13:46:17 +00:00
Serhiy Storchaka 420c636219
Add missed "f" in an f-string (GH-108906) 2023-09-05 12:00:28 +00:00
Nikita Sobolev b4c8cce9a7
gh-108840: Remove unused `TestEnumTypeSubclassing` from `test_enum` (#108841) 2023-09-05 09:45:54 +01:00
Petr Viktorin 230649f538
gh-108294: Add error handling for time.sleep audit event (GH-108363)
I've also cleaned the tests up a bit to make this easier to test.
2023-09-05 10:25:08 +02:00
Mark Shannon 5a2a046151
GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420) 2023-09-05 08:03:53 +01:00
Serhiy Storchaka 04a0830b00
gh-89392: Remove support of test_main() in libregrtest (GH-108876) 2023-09-05 08:36:43 +03:00
Victor Stinner 1170d5a292
gh-108834: regrtest --fail-rerun exits with code 5 (#108896)
When the --fail-rerun option is used and a test fails and then pass,
regrtest now uses exit code 5 ("rerun) instead of 2 ("bad test").
2023-09-05 01:09:42 +00:00
Victor Stinner 676593859e
gh-106320: Remove private _PyErr_WriteUnraisableMsg() (#108863)
Move the private _PyErr_WriteUnraisableMsg() functions to the
internal C API (pycore_pyerrors.h).

Move write_unraisable_exc() from _testcapi to _testinternalcapi.
2023-09-05 01:54:55 +02:00
Tian Gao 6304d983a0
gh-108463: Make expressions/statements work as expected in pdb (#108464) 2023-09-04 21:44:40 +00:00
Nikita Sobolev 6ead5bd6ae
Disable `differing_test_runners` health check (#108886) 2023-09-04 18:31:58 +00:00
Petr Viktorin 40e52c94a2
gh-107902: Don't test setting suid/sgid on systems that don't support them (GH-108368) 2023-09-04 15:46:00 +02:00
Serhiy Storchaka f3b6608ba2
gh-89392: Fix running test_pep646_syntax as script (GH-108875) 2023-09-04 15:24:03 +03:00
Serhiy Storchaka 074ac1f72e
bpo-45229: Make ElementTree tests discoverable (GH-108859) 2023-09-04 13:04:32 +03:00
Serhiy Storchaka d0b22f6bd8
gh-89392: Make test_pep646_syntax discoverable (GH-108861) 2023-09-04 12:41:58 +03:00
Serhiy Storchaka 76f3c043b6
gh-89392: Remove test_main() in test_netrc (GH-108860) 2023-09-04 12:41:13 +03:00
Victor Stinner 5a79d2ae57
Revert "gh-46376: Return existing pointer when possible in ctypes (#1… (#108688)
This reverts commit 08447b5deb.

Revert also _ctypes.c changes of the PyDict_ContainsString() change,
commit 6726626646.
2023-09-04 11:21:47 +02:00
Victor Stinner 31c2945f14
gh-108834: regrtest reruns failed tests in subprocesses (#108839)
When using --rerun option, regrtest now re-runs failed tests
in verbose mode in fresh worker processes to have more
deterministic behavior. So it can write its final report even
if a test killed a worker progress.

Add --fail-rerun option to regrtest: exit with non-zero exit code
if a test failed pass passed when re-run in verbose mode (in a
fresh process). That's now more useful since tests can pass
when re-run in a fresh worker progress, whereas they failed
when run after other tests when tests are run sequentially.

Rename --verbose2 option (-w) to --rerun. Keep --verbose2 as a
deprecated alias.

Changes:

* Fix and enhance statistics in regrtest summary. Add "(filtered)"
  when --match and/or --ignore options are used.
* Add RunTests class.
* Add TestResult.get_rerun_match_tests() method
* Rewrite code to serialize/deserialize worker arguments as JSON
  using a new WorkerJob class.
* Fix stats when a test is run with --forever --rerun.
* If failed test names cannot be parsed, log a warning and don't
  filter tests.
* test_regrtest.test_rerun_success() now uses a marker file, since
  the test is re-run in a separated process.
* Add tests on normalize_test_name() function.
* Add test_success() and test_skip() tests to test_regrtest.
2023-09-03 21:37:15 +00:00
Sangyun_LEE 0c369d6cb8
Update Lib/test/test_unittest/testmock/testmock.py: fix typo RuntimError to RuntimeError (#108847) 2023-09-03 22:19:49 +01:00
Serhiy Storchaka 509bb61977
Reorder some test's decorators (GH-108804)
For example, do not demand the 'cpu' resource if the test cannot be run
due to non-working threads.
2023-09-03 15:21:43 +03:00
Sergey B Kirpichev 9c995abd78
gh-102837: improve test coverage for math module (#102523)
- input checks for math_1(L989), math_1a(L1023), math_2(L1064,L1071), hypot(L2682), log(L2307), ldexp(L2168), ceil(L1165), floor(L1236,L1239) and dist(L2587,L2588,L2628).
- drop inaccessible "if" branch (L3518) in perm_comb_small()
- improve fsum coverage for exceptional cases (L1433,L1438,L1451,L1497), ditto fmod(L2378)
- rewrite modf to fix inaccessible case(L2229), ditto for pow(L2988)
    
(all line numbers are wrt the main branch at 5e6661bce9)
2023-09-03 01:48:47 -07:00
Victor Stinner d4e534cbb3
regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.

Changes:

* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
  in-place.
* libregrtest summary lists the number of run tests and skipped
  tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
  test state.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-02 18:09:36 +02:00
Barney Gale bdc3c884cd
GH-78722: Raise exceptions from `pathlib.Path.iterdir()` without delay. (#107320)
`pathlib.Path.iterdir()` now immediately raises any `OSError`
exception from `os.listdir()`, rather than waiting until its
result is iterated over.
2023-09-02 16:08:03 +01:00
Victor Stinner 4f9b706c6f
gh-108794: doctest counts skipped tests (#108795)
* Add 'skipped' attribute to TestResults.
* Add 'skips' attribute to DocTestRunner.
* Rename private DocTestRunner._name2ft attribute
  to DocTestRunner._stats.
* Use f-string for string formatting.
* Add some tests.
* Document DocTestRunner attributes and its API for statistics.
* Document TestResults class.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-02 16:42:07 +02:00
Serhiy Storchaka f3ba0a74cd
gh-108416: Mark slow test methods with @requires_resource('cpu') (GH-108421)
Only mark tests which spend significant system or user time,
by itself or in subprocesses.
2023-09-02 07:45:34 +03:00
Guido van Rossum 76ce537fb1
Fix test_regrtest when run with uops always on (#108778)
The fix has two parts:
- When `-X uops` is detected, pass it on to the subprocess created to run the manufactured test.
  I need this so I can run `./python -Xuops -m test test_regrtest` and see it fail without the next fix.
- Use `-R 6:3:` in `ArgsTestCase.test_huntrleaks` instead of `-R 3:3:` -- it takes longer to settle with `-X uops`.
2023-09-01 16:27:09 -07:00
Nikita Sobolev 3b73f9f00e
gh-107862: Add roundtrip `hypothesis` tests to `test_binascii` (#107863) 2023-09-01 21:04:07 +00:00
Alex Waygood a1cbace91b
gh-105509: Simplify implementation of `typing.Annotated` (#105510) 2023-09-01 13:57:25 -07:00
Victor Stinner 23f54c1200
Make test_fcntl quiet (#108758)
Running test_fcntl logs two "struct.pack: ..." lines because
multiprocessing imports test_fcntl twice with
test.support.verbose=1. Move get_lockdata() inside TestFcntl test
case and only call it where it's needed, to stop logging these lines.
2023-09-01 14:59:09 +02:00
Irit Katriel 844f4c2e12
gh-108727: Fix segfault due to missing tp_dealloc definition for CounterOptimizer_Type (GH-108734) 2023-09-01 10:16:09 +01:00
Nikita Sobolev 044b8b3b6a
gh-107805: Fix signatures of module-level generated functions in `turtle` (#107807)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-01 01:18:15 -07:00
Victor Stinner ad73674283
gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed,
and only includes pycore_runtime.h if _Py_ID() is needed.

* Add 'condition' optional argument to Clinic.add_include().
* deprecate_keyword_use() includes pycore_runtime.h when using
  the _PyID() function.
* Fix rendering of includes: comments start at the column 35.
* Mark PC/clinic/_wmimodule.cpp.h and
  "Objects/stringlib/clinic/*.h.h" header files as generated in
  .gitattributes.

Effects:

* 42 header files generated by AC no longer include the internal C
  API, instead of 4 header files before. For example,
  Modules/clinic/_abc.c.h no longer includes the internal C API.
* Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h
  to get _Py_ID().
2023-08-31 23:42:34 +02:00
Victor Stinner 2bd960b579
gh-108337: Add pyatomic.h header (#108701)
This adds a new header that provides atomic operations on common data
types. The intention is that this will be exposed through Python.h,
although that is not the case yet. The only immediate use is in
the test file.

Co-authored-by: Sam Gross <colesbury@gmail.com>
2023-08-31 21:41:18 +00:00
Victor Stinner c6d56135e1
gh-108638: Fix tests when _stat extension is missing (#108689)
Fix test_inspect and test_pydoc when the _stat extension is missing.
Skip tests relying on _stat when _stat is missing.
2023-08-31 23:14:23 +02:00
Ethan Furman d48760b2f1
gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ (GH-108704)
When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. .

    member = object.__new__(cls)
    member = int.__new__(cls, value)
    member = str.__new__(cls, value)

Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.
2023-08-31 12:45:12 -07:00
Victor Stinner 13a00078b8
gh-108634: Py_TRACE_REFS uses a hash table (#108663)
Python built with "configure --with-trace-refs" (tracing references)
is now ABI compatible with Python release build and debug build.
Moreover, it now also supports the Limited API.

Change Py_TRACE_REFS build:

* Remove _PyObject_EXTRA_INIT macro.
* The PyObject structure no longer has two extra members (_ob_prev
  and _ob_next).
* Use a hash table (_Py_hashtable_t) to trace references (all
  objects): PyInterpreterState.object_state.refchain.
* Py_TRACE_REFS build is now ABI compatible with release build and
  debug build.
* Limited C API extensions can now be built with Py_TRACE_REFS:
  xxlimited, xxlimited_35, _testclinic_limited.
* No longer rename PyModule_Create2() and PyModule_FromDefAndSpec2()
  functions to PyModule_Create2TraceRefs() and
  PyModule_FromDefAndSpec2TraceRefs().
* _Py_PrintReferenceAddresses() is now called before
  finalize_interp_delete() which deletes the refchain hash table.
* test_tracemalloc find_trace() now also filters by size to ignore
  the memory allocated by _PyRefchain_Trace().

Test changes for Py_TRACE_REFS:

* Add test.support.Py_TRACE_REFS constant.
* Add test_sys.test_getobjects() to test sys.getobjects() function.
* test_exceptions skips test_recursion_normalizing_with_no_memory()
  and test_memory_error_in_PyErr_PrintEx() if Python is built with
  Py_TRACE_REFS.
* test_repl skips test_no_memory().
* test_capi skisp test_set_nomemory().
2023-08-31 18:33:34 +02:00
Victor Stinner 79823c103b
gh-106320: Remove private _PyErr_ChainExceptions() (#108713)
Remove _PyErr_ChainExceptions(), _PyErr_ChainExceptions1() and
_PyErr_SetFromPyStatus() functions from the public C API.

* Move the private _PyErr_ChainExceptions() and
  _PyErr_ChainExceptions1() function to the internal C API
  (pycore_pyerrors.h).
* Move the private _PyErr_SetFromPyStatus() to the internal C API
  (pycore_initconfig.h).
* No longer export the _PyErr_ChainExceptions() function.
* Move run_in_subinterp_with_config() from _testcapi to
  _testinternalcapi.
2023-08-31 13:53:19 +02:00
Carl Meyer 157b89e55e
gh-108696: revert bypassing import cache in test_import helper (#108698) 2023-08-30 18:15:31 -06:00
Carl Meyer d52c4482a8
gh-108654: restore comprehension locals before handling exception (#108659)
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2023-08-30 17:50:50 -06:00
Victor Stinner f59c66e8c8
gh-108297: Remove test_crashers (#108690)
The test was skipped in 2011 by
commit 89ba56d5fb.

Scripts in Lib/test/crashers/ do not crash on a reliable way. They
rely on undefined behaviors, like state of the stack memory, and so
may or may not crash. It is not worth it to make sure that they crash
in a continious integration, they should be run manually time to time
instead.
2023-08-30 21:33:04 +02:00
albanD add8d45cbe
gh-108520: Fix bad fork detection in nested multiprocessing use case (#108568)
gh-107275 introduced a regression where a SemLock would fail being passed along nested child processes, as the `is_fork_ctx` attribute would be left missing after the first deserialization.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2023-08-30 17:07:41 +00:00
Erlend E. Aasland 2a3926fa51
gh-108590: Revert gh-108657 (commit 400a1cebc) (#108686)
Reverted per Serhiy's request.
2023-08-30 14:53:10 +00:00
Corvin 400a1cebc7
gh-108590: Fix sqlite3.iterdump for invalid Unicode in TEXT columns (#108657)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-30 09:06:21 +00:00
Serhiy Storchaka 210a5d7b8b
Revert "gh-103224: Use the realpath of the Python executable in `test_venv` (GH-103243)" (GH-108667)
This reverts commit 85b0b0cd94.

It broke builtbots.
2023-08-30 11:41:04 +03:00
Serhiy Storchaka d08d49dd09
Revert "Use non alternate name for Kyiv (GH-108533)" (GH-108649)
This reverts commit 7659128b9d.

It broke tests on the Debian and macOS buildbots.
2023-08-29 23:08:45 +03:00
Erlend E. Aasland 0b0c1d046c
gh-108278: Deprecate passing the first param of sqlite3.Connection callback APIs by keyword (#108632)
Deprecate passing the callback callable by keyword for the following
sqlite3.Connection APIs:

- set_authorizer(authorizer_callback)
- set_progress_handler(progress_handler, ...)
- set_trace_callback(trace_callback)

The affected parameters will become positional-only in Python 3.15.
2023-08-29 22:02:12 +02:00
Guido van Rossum 59e46932c8
gh-108488: Initialize JUMP_BACKWARD cache to 0, not 17 (#108591)
This mis-initialization caused the executor optimization to kick in sooner than intended. It also set the lower 4 bits of the counter to `1` -- those bits are supposed to be reserved (the actual counter is in the upper 12 bits).
2023-08-29 18:14:56 +00:00
Victor Stinner 83e191ba76
test_sys: remove debug print() (#108642) 2023-08-29 16:04:07 +00:00
Victor Stinner b62a76043e
gh-108638: Fix stat.filemode() when _stat is missing (#108639)
Change the pure Python implementation of stat.filemode() for unknown
file type: use "?", as done by the _stat.filemode().

test_stat skips TestFilemodeCStat if the _stat extension is missing.
2023-08-29 15:46:46 +00:00
Jochen Sprickerhof 7659128b9d
Use non alternate name for Kyiv (GH-108533)
tzdata provides Kiev as an alternative to Kyiv:

https://sources.debian.org/src/tzdata/2023c-10/backward/?hl=314#L314

But Debian moved it to the tzdata-legacy package breaking the test:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050530

This patch switches to the name provided by tzdata.
2023-08-29 18:00:43 +03:00
Serhiy Storchaka ecb2bf02a4
gh-108617: Extend interactive session tests for sqlite3 (GH-108556) 2023-08-29 13:20:32 +03:00
Edward Schauman-Haigh 6eaddc10e9
gh-108558: Improve sqlite3 row factory tests (#108578)
Add test_sqlite_row_keys() to explicitly test sqlite3.Row.keys().

Cleanups:
- Reduce test noise by converting docstrings to regular comments
- Reduce boilerplate code by adding a setUp() method to RowFactoryTests

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-29 08:51:36 +00:00
Adam Turner 0bd2ba553d
GH-107603: Clinic: Pass specific attributes to ``print_block()`` (#108581) 2023-08-28 21:31:45 +00:00
Matthias Bussonnier f75cefd402
gh-106670: Allow Pdb to move between chained exceptions (#106676) 2023-08-28 18:31:03 +00:00
Alex Waygood 242bef459b
gh-108494: Argument clinic: Improve the `parse_file()` API (#108575)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-08-28 18:25:16 +00:00
Erlend E. Aasland 4116592b6f
gh-108278: Deprecate passing the three first params as keyword args for sqlite3 UDF creation APIs (#108281)
Deprecate passing name, number of arguments, and the callable as keyword
arguments, for the following sqlite3.Connection APIs:

- create_function(name, nargs, callable, ...)
- create_aggregate(name, nargs, callable)

The affected parameters will become positional-only in Python 3.15.
2023-08-28 13:32:07 +00:00
Serhiy Storchaka bc5356bb5d
gh-108494: Argument Clinic: fix support of Limited C API (GH-108536) 2023-08-28 16:04:27 +03:00
Erlend E. Aasland d90973340b
gh-104683: Argument Clinic: Refactor the module and class resolver (#108552) 2023-08-28 14:41:05 +02:00
Erlend E. Aasland 0e8b3fc718
gh-108550: Speed up sqlite3 tests (#108551)
Refactor the CLI so we can easily invoke it and mock command-line
arguments. Adapt the CLI tests so we no longer have to launch a
separate process.

Disable the busy handler for all concurrency tests; we have full
control over the order of the SQLite C API calls, so we can safely
do this.

The sqlite3 test suite now completes ~8 times faster than before.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-28 14:17:34 +02:00
Erlend E. Aasland d0160c7c22
gh-64662: Add virtual table support to sqlite3.Connection.iterdump (#108340)
Co-authored-by: Aviv Palivoda <palaviv@gmail.com>
2023-08-28 00:18:32 +02:00
Jelle Zijlstra 482fad7f01
gh-108295: Fix crashes with TypeVar weakrefs (#108517) 2023-08-26 17:13:33 -07:00
denballakh e407cea193
gh-107406: Add better `struct.Struct` repr (#107407) 2023-08-26 15:24:16 +05:30
Victor Stinner 86bc9e35c4
gh-108494: AC supports pos-only args in limited C API (#108498)
AC now checks for "#define Py_LIMITED_API" pattern to use the limited
C API.
2023-08-26 00:39:24 +02:00
Victor Stinner 1dd9510977
gh-108494: Argument Clinic partial supports of Limited C API (#108495)
Argument Clinic now has a partial support of the
Limited API:

* Add --limited option to clinic.c.
* Add '_testclinic_limited' extension which is built with
  the limited C API version 3.13.
* For now, hardcode in clinic.py that "_testclinic_limited.c" targets
  the limited C API.
2023-08-25 23:22:08 +02:00
Guido van Rossum 5347018409
gh-108311: Fix test_store_attr_with_hint by disabling optimizer in decorator (#108312)
See https://github.com/python/cpython/issues/108311#issuecomment-1693569380

---------

Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-08-25 16:40:27 +00:00
Mark Shannon bc2f9e6258
gh-107932: Fix merge conflict in test_dis (GH-108478)
Fix merge conflict in test_dis
2023-08-25 13:02:10 +01:00
Serhiy Storchaka 4ae3edf300
gh-108418: Speed up bigmem compression tests in dry mode (GH-108419)
Only generate and compress small amount of random data in dry run.
2023-08-25 12:37:27 +03:00
Corvin 24aa249a66
gh-107932: Fix dis module for bytecode that does not have an associated source line (GH-107988) 2023-08-25 09:31:26 +01:00
Peeyush Aggarwal 8d4052075e
gh-103384: Generalize the regex pattern `BaseConfigurator.INDEX_PATTERN` to allow spaces and non-alphanumeric characters in keys. (GH-103391)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-25 09:15:26 +01:00
Victor Stinner 4e5a7284ee
gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)
Argument Clinic now uses the new public PyLong_AsInt(), rather than
the old name _PyLong_AsInt().
2023-08-25 00:51:22 +02:00
Victor Stinner be436e08b8
gh-108444: Add PyLong_AsInt() public function (#108445)
* Rename _PyLong_AsInt() to PyLong_AsInt().
* Add documentation.
* Add test.
* For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().
2023-08-24 23:55:30 +02:00
Filipe Laíns feb9a49c9c
GH-103247: bypass the import cache on the _require_loader helper 2023-08-24 21:05:03 +00:00
Victor Stinner 26893016a7
gh-106320: Remove private _PyDict functions (#108449)
Move private functions to the internal C API (pycore_dict.h):

* _PyDictView_Intersect()
* _PyDictView_New()
* _PyDict_ContainsId()
* _PyDict_DelItemId()
* _PyDict_DelItem_KnownHash()
* _PyDict_GetItemIdWithError()
* _PyDict_GetItem_KnownHash()
* _PyDict_HasSplitTable()
* _PyDict_NewPresized()
* _PyDict_Next()
* _PyDict_Pop()
* _PyDict_SetItemId()
* _PyDict_SetItem_KnownHash()
* _PyDict_SizeOf()

No longer export most of these functions.

Move also the _PyDictViewObject structure to the internal C API.

Move dict_getitem_knownhash() function from _testcapi to the
_testinternalcapi extension. Update test_capi.test_dict for this
change.
2023-08-24 20:01:50 +00:00
Victor Stinner 995f4c48e1
gh-80527: Change support.requires_legacy_unicode_capi() (#108438)
The decorator now requires to be called with parenthesis:

    @support.requires_legacy_unicode_capi()

instead of:

    @support.requires_legacy_unicode_capi

The implementation now only imports _testcapi when the decorator is
called, so "import test.support" no longer imports the _testcapi
extension.
2023-08-24 20:09:23 +02:00
Victor Stinner 480a337366
gh-106320: Remove private _PyContext_NewHamtForTests() (#108434)
Move the function to the internal C API.
2023-08-24 19:37:41 +02:00
Victor Stinner aa6f787faa
gh-108388: Convert test_concurrent_futures to package (#108401)
Convert test_concurrent_futures to a package of sub-tests.
2023-08-24 19:21:44 +02:00
Victor Stinner 6726626646
gh-108314: Add PyDict_ContainsString() function (#108323) 2023-08-24 15:59:12 +02:00
Chris Markiewicz 2eb60c1934
gh-108111: Flush gzip write buffer before seeking, fixing bad writes (#108341)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-08-24 10:23:01 +02:00
Victor Stinner aa9a359ca2
gh-108388: Split test_multiprocessing_spawn (#108396)
Split test_multiprocessing_fork, test_multiprocessing_forkserver and
test_multiprocessing_spawn into test packages. Each package is made
of 4 sub-tests: processes, threads, manager and misc. It allows
running more tests in parallel and so reduce the total test duration.
2023-08-24 05:35:39 +02:00
Victor Stinner 174e9da083
gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".

Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
2023-08-24 02:44:58 +00:00
Victor Stinner 7a6cc3eb66
test_peg_generator and test_freeze require cpu (#108386)
The test_peg_generator and test_tools.test_freeze tests now require
the 'cpu' resource. Skip these tests unless the 'cpu' resource is
enabled (it is disabled by default).

These tests are no longer skipped if Python is built with ASAN or
MSAN sanitizer.
2023-08-24 00:52:48 +02:00
Victor Stinner 592bacb6fc
gh-108342: Make ssl TestPreHandshakeClose more reliable (#108370)
* In preauth tests of test_ssl, explicitly break reference cycles
  invoving SingleConnectionTestServerThread to make sure that the
  thread is deleted. Otherwise, the test marks the environment as
  altered because the threading module sees a "dangling thread"
  (SingleConnectionTestServerThread). This test leak was introduced
  by the test added for the fix of issue gh-108310.
* Use support.SHORT_TIMEOUT instead of hardcoded 1.0 or 2.0 seconds
  timeout.
* SingleConnectionTestServerThread.run() catchs TimeoutError
* Fix a race condition (missing synchronization) in
  test_preauth_data_to_tls_client(): the server now waits until the
  client connect() completed in call_after_accept().
* test_https_client_non_tls_response_ignored() calls server.join()
  explicitly.
* Replace "localhost" with server.listener.getsockname()[0].
2023-08-23 21:57:11 +00:00
albanD 1700d34d31
gh-77377: Ensure multiprocessing SemLock is valid for spawn-based Process before serializing it (#107275)
Ensure multiprocessing SemLock is valid for spawn Process before serializing it.

Creating a multiprocessing SemLock with a fork context, and then trying to pass it to a spawn-created Process, would segfault if not detected early.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2023-08-23 20:27:35 +00:00
Nikita Sobolev 3f61cf646d
gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354) 2023-08-23 17:42:08 +02:00
Serhiy Storchaka 154477be72
gh-50002: xml.dom.minidom now preserves whitespaces in attributes (GH-107947)
Also double quotes (") are now only quoted in attributes.
2023-08-23 15:23:41 +03:00
Mariusz Felisiak 29bc6165ab
gh-105539: Fix ResourceWarning from unclosed SQLite connections in test_sqlite3 (#108360)
Follow up to 1a1bfc2891.

Explicitly manage connections in:

- test_audit.test_sqlite3
- test_sqlite3.test_audit
- test_sqlite3.test_backup

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2023-08-23 10:10:08 +00:00
Petr Viktorin 31b61d19ab
gh-108294: Add time.sleep audit event (GH-108298) 2023-08-23 11:00:22 +02:00
Irit Katriel 2dfbd4f36d
gh-108113: Make it possible to optimize an AST (#108282) 2023-08-23 09:01:17 +01:00
Victor Stinner 9173b2bbe1
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)
Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.
2023-08-23 02:52:56 +00:00
Victor Stinner 3a1ac87f8f
gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
2023-08-23 01:39:50 +02:00
Victor Stinner 21dda09600
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)
* Move test_cppext to its own directory
* Rename setup_testcppext.py to setup.py
* Rename _testcppext.cpp to extension.cpp
* The source (extension.cpp) is now also copied by the test.
2023-08-22 18:30:18 +00:00
Łukasz Langa 0cb0c238d5
gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108315)
Instances of `ssl.SSLSocket` were vulnerable to a bypass of the TLS handshake
and included protections (like certificate verification) and treating sent
unencrypted data as if it were post-handshake TLS encrypted data.

The vulnerability is caused when a socket is connected, data is sent by the
malicious peer and stored in a buffer, and then the malicious peer closes the
socket within a small timing window before the other peers’ TLS handshake can
begin. After this sequence of events the closed socket will not immediately
attempt a TLS handshake due to not being connected but will also allow the
buffered data to be read as if a successful TLS handshake had occurred.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-08-22 19:53:15 +02:00
Victor Stinner d2879f2095
gh-108303: Remove unused Lib/test/sgml_input.html (#108305)
In Python 2.7, the file was used by Lib/test/test_sgmllib.py to test
Lib/sgmllib.py. The sgmllib module and its tests have been removed in
Python 3.0.
2023-08-22 19:12:51 +02:00
Victor Stinner adfc118fda
gh-106016: Add Lib/test/test_module/ directory (#108293)
* Move Python scripts related to test_module to this new directory:
  good_getattr.py and bad_getattrX.py scripts.
* Move Lib/test/test_module.py to Lib/test/test_module/__init__.py.
2023-08-22 16:53:49 +02:00
Victor Stinner a541e01537
gh-90791: Enable test___all__ on ASAN build (#108286)
* Only skip modules and tests related to X11 on ASAN builds: run
  other tests with ASAN.
* Use print(flush=True) to see output earlier when it's redirected to
  a pipe.
* Update issue reference: replace bpo-46633 with gh-90791.
2023-08-22 15:52:32 +02:00
Erlend E. Aasland 1a1bfc2891
gh-105539: Emit ResourceWarning if sqlite3 database is not closed explicitly (#108015) 2023-08-22 13:10:29 +02:00
Dennis Sweeney 86617518c4
gh-108179: Add error message for parser stack overflows (#108256) 2023-08-22 08:41:50 +01:00
Victor Stinner 58f9c63500
Fix test_faulthandler for sanitizers (#108245)
Set environment options to ask sanitizers to not handle SIGSEGV.

This change allows running test_enable_fd() and test_enable_file()
with sanitizers. Previously, they were skipped.
2023-08-22 01:16:12 +00:00
Steve Dower de33b5c662
gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)
* gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls

* Update 2023-08-22-00-36-57.gh-issue-106242.q24ITw.rst

mention Windows and the former incorrect ValueError.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-08-22 00:16:02 +00:00
Victor Stinner 531930f47f
Fix test_generators: save/restore warnings filters (#108246)
Previously, depending on existing filters, the test
could modify the warnings and so fail as "env changed".
2023-08-21 23:41:13 +00:00
Irit Katriel a1cc74c4ee
gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop (#108242) 2023-08-21 23:44:31 +01:00
Dong-hee Na e6db23f66d
gh-107265: Fix code_hash for ENTER_EXECUTOR case (#108188) 2023-08-21 14:22:18 -07:00
Victor Stinner 5afe0c17ca
gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:

    $ make pythoninfo|grep NOGIL
    sysconfig[Py_NOGIL]: 1

    $ ./python -m test
    ...
    == Python build: nogil debug
    ...
2023-08-21 22:16:23 +02:00
Irit Katriel 10a91d7e98
gh-108113: Make it possible to create an optimized AST (#108154) 2023-08-21 16:31:30 +00:00
Serhiy Storchaka 60942cccb1
gh-95065, gh-107704: Argument Clinic: support multiple '/ [from ...]' and '* [from ...]' markers (GH-108132) 2023-08-21 13:59:58 +00:00
Nikita Sobolev 13104f3b74
gh-107905: Test raising `__value__` for `TypeAliasType` (#107997) 2023-08-21 13:52:37 +00:00
balmeida-nokia 37135d25e2
gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485)
In the stack call of: _init_read_gz()
```
_read, tarfile.py:548
read, tarfile.py:526
_init_read_gz, tarfile.py:491
```
a try;except exists that uses `self.exception`, so it needs to be set before
calling _init_read_gz().
2023-08-21 11:39:06 +00:00
Petr Viktorin acbd3f9c5c
gh-107845: Fix symlink handling for tarfile.data_filter (GH-107846)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Lumír 'Frenzy' Balhar <frenzy.madness@gmail.com>
2023-08-21 12:56:46 +02:00
Raymond Hettinger 20cc90c0df
gh-105736: Sync pure python version of OrderedDict with the C version (#108098) 2023-08-21 11:49:08 +02:00
Joon Hwan 김준환 014a5b71e7
gh-107895: Fix test_asyncio.test_runners when run it in CPython's "development mode" (GH-108168) 2023-08-21 07:55:09 +00:00
Dong-hee Na 4fdf3fda0f
gh-107265: Fix code_richcompare for ENTER_EXECUTOR case (gh-108165) 2023-08-21 05:50:09 +00:00
Dong-hee Na 04f7875c44
gh-107526: Fix test_module_level_callable_unrepresentable_default (gh-108187) 2023-08-21 04:51:31 +00:00
Serhiy Storchaka 633ea217a8
gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918)
Such C API functions as PyErr_SetString(), PyErr_Format(),
PyErr_SetFromErrnoWithFilename() and many others no longer crash or
ignore errors if it failed to format the error message or decode the
filename. Instead, they keep a corresponding error.
2023-08-19 14:51:03 +03:00
Serhiy Storchaka 79db9d9a0e
gh-72684: Tkinter: provide interface for "tk busy" subcommands (GH-107684)
Add tkinter.Misc methods: tk_busy_hold(), tk_busy_configure(), tk_busy_cget(),
tk_busy_forget(), tk_busy_current(), and tk_busy_status().
2023-08-19 14:48:02 +03:00
Serhiy Storchaka 2f311437cd
gh-107704: Argument Clinic: add support for deprecating keyword use of parameters (GH-107984)
It is now possible to deprecate passing keyword arguments for
keyword-or-positional parameters with Argument Clinic, using the new
'/ [from X.Y]' syntax.
(To be read as "positional-only from Python version X.Y")

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-19 10:13:35 +03:00
Tyler Smart 9bb576cb07
gh-107995: Fix doctest collection of functools.cached_property objects (#107996)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-18 15:44:38 +00:00
Pablo Galindo Salgado 75b3db8445
gh-107944: Improve error message for function calls with bad keyword arguments (#107969) 2023-08-17 19:39:42 +01:00
Guido van Rossum 61c7249759
gh-106581: Project through calls (#108067)
This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
2023-08-17 11:29:58 -07:00
Nikita Sobolev 80f30cf51b
gh-102029: Deprecate passing arguments to `_PyRLock` in `threading` (#102071) 2023-08-17 09:19:07 -07:00
Erlend E. Aasland 1344cfac43
gh-105539: Explict resource management for connection objects in sqlite3 tests (#108017)
- Use memory_database() helper
- Move test utility functions to util.py
- Add convenience memory database mixin
- Add check() helper for closed connection tests
2023-08-17 08:45:48 +02:00
Guido van Rossum dc8fdf5fd5
gh-106581: Split `CALL_PY_EXACT_ARGS` into uops (#107760)
* Split `CALL_PY_EXACT_ARGS` into uops

This is only the first step for doing `CALL` in Tier 2.
The next step involves tracing into the called code object and back.
After that we'll have to do the remaining `CALL` specialization.
Finally we'll have to deal with `KW_NAMES`.

Note: this moves setting `frame->return_offset` directly in front of
`DISPATCH_INLINED()`, to make it easier to move it into `_PUSH_FRAME`.
2023-08-16 16:26:43 -07:00
Irit Katriel 665a4391e1
gh-105481: generate op IDs from bytecode.c instead of hard coding them in opcode.py (#107971) 2023-08-16 22:25:18 +00:00
Serhiy Storchaka 882cb79afa
gh-56166: Deprecate passing confusing positional arguments in re functions (#107778)
Deprecate passing optional arguments maxsplit, count and flags in
module-level functions re.split(), re.sub() and re.subn() as positional.
They should only be passed by keyword.
2023-08-16 13:35:35 -07:00
Nikita Sobolev 199438b7cc
gh-105522: [Enum] Correctly handle possible exceptions during testing (GH-105523) 2023-08-16 12:17:28 -07:00
Carl Meyer fce93c80ae
gh-91051: fix type watcher test to be robust to existing watcher (#107989) 2023-08-16 13:13:32 -06:00
Erlend E. Aasland 42429d3b9a
gh-104683: Argument Clinic: Extract parse function name helper (#107964)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-16 13:47:15 +00:00
Nikita Sobolev b61f5995ae
gh-107909: Test explicit `object` base in PEP695 generic classes (#108001) 2023-08-16 06:30:03 -07:00
Nikita Sobolev a8d440b383
gh-108000: Test that `lambda` also has `__type_params__` (#108002) 2023-08-16 06:22:18 -07:00
Erlend E. Aasland 57a20b0960
gh-106368: Argument Clinic: Test that keyword params are disallowed in groups (#107985) 2023-08-16 12:39:56 +02:00
Nikita Sobolev bdd8ddfda1
gh-105724: Add location information to `assert` errors (GH-105935) 2023-08-16 11:35:38 +01:00
Nikita Sobolev fd9d70a94d
gh-106300: Improve errors testing in test_unittest.test_runner (GH-106737)
Use a custom exception to prevent unintentional silence of actual errors.
2023-08-16 12:20:42 +03:00
SKO abd9cc52d9
gh-100061: Proper fix of the bug in the matching of possessive quantifiers (GH-102612)
Restore the global Input Stream pointer after trying to match a sub-pattern.

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
2023-08-16 10:43:45 +03:00
6t8k a86df298df
gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802)
Restore following CPython <= 3.10.5 behavior of shutil.make_archive()
that went away as part of gh-93160:

Do not create an empty archive if root_dir is not a directory, and, in
that case, raise FileNotFoundError or NotADirectoryError regardless
of format choice. Beyond the brought-back behavior, the function may
now also raise these exceptions in dry_run mode.
2023-08-16 10:00:03 +03:00
Erlend E. Aasland bb456a08a3
gh-106368: Argument Clinic: Add tests for cloned functions with custom C base names (#107977) 2023-08-15 14:45:53 -06:00
Finn Womack 0932272431
gh-106242: Fix path truncation in os.path.normpath (GH-106816) 2023-08-15 16:33:00 +01:00
Erlend E. Aasland 607f18c894
gh-107972: Argument Clinic: Ensure a C basename is provided after 'as' (#107973)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-08-15 14:41:40 +00:00
Erlend E. Aasland e90036c9bd
gh-107880: Argument Clinic: Fix regression in gh-107885 (#107974)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-15 14:00:52 +00:00
Dong-hee Na 6515ec3d3d
gh-107963: Fix set_forkserver_preload to check the type of given list (#107965)
gh-107963: Fix set_forkserver_preload to check the type of given list
2023-08-15 15:58:12 +02:00
Lysandros Nikolaou d66bc9e8a7
gh-107967: Fix infinite recursion on invalid escape sequence warning (#107968) 2023-08-15 11:26:42 +00:00
Erlend E. Aasland 13c36dc9ae
gh-93057: Deprecate positional use of optional sqlite3.connect() params (#107948) 2023-08-15 08:09:56 +00:00
Romuald Brunet a482e5bf00
gh-76913: Add "merge extras" feature to LoggerAdapter (GH-107292) 2023-08-15 08:23:54 +01:00
Joon Hwan 김준환 c3887b57a7
gh-107910: Remove not needing newline in error message (GH-107928) 2023-08-14 12:26:18 +03:00
Erlend E. Aasland 9b75ada6e4
gh-107880: Teach Argument Clinic to clone __init__ and __new__ methods (#107885) 2023-08-13 12:13:11 +02:00
Erlend E. Aasland ee40b3e20d
gh-107883: Argument Clinic: Handle full module/class path in Function.fulldisplayname (#107884)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-12 23:46:00 +00:00
Nikita Sobolev d93b4ac2ff
gh-101162: Forbid using issubclass() with GenericAlias as the 1st arg (GH-103369) 2023-08-11 22:12:11 +03:00
Carl Meyer 66e4edd734
gh-91051: fix segfault when using all 8 type watchers (#107853) 2023-08-11 12:42:26 -06:00
Serhiy Storchaka 04cc01453d
gh-106844: Fix issues in _winapi.LCMapStringEx (GH-107832)
* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError,
   it doesn't matter how much memory is available.
* Strings with length exactly 2**32-1 caused OSError.
* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.
* Strings containing the null character were truncated at the first null character.

Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed.
2023-08-11 21:13:46 +03:00
Serhiy Storchaka a39f0a3506
gh-107782: Pydoc: fall back to __text_signature__ if inspect.signature() fails (GH-107786)
It allows to show signatures which are not representable in Python,
e.g. for getattr and dict.pop.
2023-08-11 20:51:36 +03:00
Andrew Geng 5f7d4ecf30
gh-106558: break ref cycles through exceptions in multiprocessing manager (#106559) 2023-08-11 17:44:18 +00:00
Raymond Hettinger 52e0797f8e
Extend _sqrtprod() to cover the full range of inputs. Add tests. (GH-107855) 2023-08-11 11:19:19 -05:00
Serhiy Storchaka 3901c991e1
gh-84805: Autogenerate signature for METH_NOARGS and METH_O extension functions (GH-107794) 2023-08-11 18:08:38 +03:00
Marc Mueller 16dcce2176
gh-107810: Improve DeprecationWarning for metaclasses with custom tp_new (GH-107834)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2023-08-10 15:55:47 +00:00
Eric V. Smith e4275f4df3
gh-107838: In dataclasses, improve error message when a non-default field follows a default field. (gh-107842)
Add the name of the previous default argument field in an error message.
2023-08-10 10:39:13 -04:00
Mark Shannon 1d976b2da2
GH-106485: Handle dict subclasses correctly when dematerializing `__dict__` (GH-107837) 2023-08-10 13:34:00 +01:00
Mark Shannon 494e3d4436
GH-107774: Add missing audit event for PEP 669 (GH-107775) 2023-08-10 12:29:06 +01:00
Erlend E. Aasland 39ef93edb9
gh-95065: Argument Clinic: Add functional tests of deprecated positionals (#107768)
Move the "deprecated positinal" tests from clinic.test.c to
_testclinic.c. Mock PY_VERSION_HEX in order to prevent generated
compiler warnings/errors to trigger. Put clinic code for deprecated
positionals in Modules/clinic/_testclinic_depr_star.c.h for easy
inspection of the generated code.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-10 07:19:05 +00:00
denballakh 4845b9712f
gh-107409: set `__wrapped__` attribute in `reprlib.recursive_repr` (#107410)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2023-08-10 06:55:49 +00:00
Brandt Bucher 326f0ba1c5
GH-106485: Dematerialize instance dictionaries when possible (GH-106539) 2023-08-09 19:14:50 +00:00
Brandt Bucher a9caf9cf90
GH-105848: Simplify the arrangement of CALL's stack (GH-107788) 2023-08-09 18:19:39 +00:00
Erlend E. Aasland 0a7f48b9a8
gh-95065: Produce nicer deprecation messages in Argument Clinic (#107808) 2023-08-09 13:28:18 +00:00
Erlend E. Aasland 1b3f5f24af
gh-104683: Argument Clinic: Params now render their own docstrings (#107790)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-09 12:44:26 +00:00
Alex Waygood 65ce3652fa
gh-104683: Remove unused variables from `Tools/clinic` and tests for `Tools/clinic` (#107771) 2023-08-09 11:24:05 +01:00
Mark Shannon 52fbcf61b5
GH-107724: Fix the signature of `PY_THROW` callback functions. (GH-107725) 2023-08-09 09:30:50 +01:00
Serhiy Storchaka 7b6e34e5ba
gh-106052: Fix bug in the matching of possessive quantifiers (gh-106515)
It did not work in the case of a subpattern containing backtracking.

Temporary implement possessive quantifiers as equivalent greedy qualifiers
in atomic groups.
2023-08-09 08:47:57 +03:00
Erlend E. Aasland 0be3743f54
gh-104683: Add --exclude option to Argument Clinic CLI (#107770)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-08 20:50:54 +00:00
Eric Snow f9e3ff1ea4
gh-105699: Re-enable the Multiple-Interpreters Stress Tests (gh-107572)
We had disabled them due to crashes they exposed, which have since been fixed.
2023-08-08 09:52:13 -06:00
Alex Waygood 7c5153de5a
gh-106368: Argument clinic: add tests for more failure paths (#107731) 2023-08-08 12:12:49 +00:00
Erlend E. Aasland 5df8b0d5c7
gh-95065: Argument Clinic: Add comment to preprocessor warning code (#107766) 2023-08-08 08:43:41 +00:00
Erlend E. Aasland 0db043dd5a
gh-95065: Make Argument Clinic append deprecation warnings to docstrings (#107745) 2023-08-08 08:41:09 +02:00
Eric Snow 707018cc75
gh-107630: Fix Remaining Subinterpreters Crashes on Py_TRACE_REFS Builds (gh-107750)
This is a follow-up to gh-107567 and gh-107733.

We skip test_basic_multiple_interpreters_deleted_no_reset on tracerefs builds.  The test breaks interpreter isolation a little, which doesn't work well with Py_TRACE_REFS builds, so I feel fine about skipping the test.
2023-08-07 17:10:57 -06:00
Serhiy Storchaka 0191af97a6
gh-107735: Move just added C API tests to better place (GH-107743) 2023-08-07 21:04:11 +00:00