Commit Graph

27022 Commits

Author SHA1 Message Date
Gregory P. Smith d315722564
gh-98433: Fix quadratic time idna decoding. (#99092)
There was an unnecessary quadratic loop in idna decoding. This restores
the behavior to linear.

This also adds an early length check in IDNA decoding to outright reject
huge inputs early on given the ultimate result is defined to be 63 or fewer
characters.
2022-11-07 16:54:41 -08:00
Hugo van Kemenade 9430d27355
gh-98817: Remove PCbuild/lib.pyproj (GH-98818) 2022-11-07 20:23:35 +00:00
Mark Shannon 4a1c58d504
GH-96793: Specialize FOR_ITER for generators. (GH-98772) 2022-11-07 14:49:51 +00:00
Noam Cohen 80c08d1cd6
gh-95389: expose popular ETHERTYPE_* constants in the socket module (#95390)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-11-07 15:27:37 +01:00
Zackery Spytz 5ff81da6d3
bpo-38523: ignore_dangling_symlinks does not apply recursively (GH-22937) 2022-11-07 11:45:16 +00:00
andrei kulakov c6325b1c9f
gh-91803: Mock - fix error when using autospec methods with seal (#92213)
Fixes https://github.com/python/cpython/issues/91803.

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2022-11-07 07:24:46 +00:00
Nikita Sobolev bef9efabc3
GH-99155: Fix `NormalDist` pickle with `0` and `1` protocols (GH99156) 2022-11-06 20:56:41 -06:00
Dong-hee Na f626b7b504
gh-96055: Update faulthandler to emit proper unexpect signal number (gh-99162) 2022-11-07 10:19:25 +09:00
Wenzel Jakob 57a405213c
gh-98586: Add What's New entry and update docs (#99056)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-11-06 23:54:55 +01:00
Anh71me bd221c01dd
gh-98139: enhance namespace package repr 2022-11-06 22:13:40 +00:00
Guido van Rossum 7dcd28eb41
GH-98831: Implement super-instruction generation (#99084)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-11-06 09:40:47 -08:00
Irit Katriel 61b6c40b64
gh-99153: set location on SyntaxError for try with both except and except* (GH-99160) 2022-11-06 15:36:19 +00:00
Shantanu d3b82b4463
gh-83004: Clean up refleak in _pickle initialisation (#98841) 2022-11-06 06:05:13 -08:00
Shantanu 31f2f6568d
gh-83004: Clean up refleak in _zoneinfo initialisation (#98842) 2022-11-06 06:04:36 -08:00
Pablo Galindo Salgado 99e2e60cb2
gh-99139: Improve NameError error suggestion for instances (#99140) 2022-11-06 13:52:06 +00:00
Ethan Furman 8feb7ab77c
gh-93464: [Enum] fix auto() failure during multiple assignment (GH-99148)
* fix auto() failure during multiple assignment

i.e. `ONE = auto(), 'text'` will now have `ONE' with the value of `(1,
'text')`.  Before it would have been `(<an auto instance>, 'text')`
2022-11-05 18:01:08 -07:00
Paul Moore 47ab8480e7
gh-99134: Update bundled pip to 22.3.1 (gh-99135)
Update bundled pip to 22.3.1
2022-11-05 17:50:39 +00:00
Kaushik Kulkarni 67ade403a2
gh-98284: better error message for undefined abstractmethod (#97971) 2022-11-05 09:31:57 -07:00
Sam James 12078e78f6
gh-99086: Fix implicit int compiler warning in configure check for PTHREAD_SCOPE_SYSTEM (#99085) 2022-11-05 09:30:31 +01:00
Victor Stinner 0faa0ba240
gh-92584: Remove the distutils package (#99061)
Remove the distutils package. It was deprecated in Python 3.10 by PEP
632 "Deprecate distutils module". For projects still using distutils
and cannot be updated to something else, the setuptools project can
be installed: it still provides distutils.

* Remove Lib/distutils/ directory
* Remove test_distutils
* Remove references to distutils
* Skip test_check_c_globals and test_peg_generator since they use
  distutils
2022-11-03 19:27:27 +01:00
Victor Stinner b07f546ea3
gh-98978: Fix Py_SetPythonHome(NULL) (#99066)
Fix use-after-free in Py_SetPythonHome(NULL), Py_SetProgramName(NULL)
and _Py_SetProgramFullPath(NULL) function calls.

Issue reported by Benedikt Reinartz.
2022-11-03 18:34:32 +01:00
Victor Stinner ef0e72b31d
gh-94172: Remove keyfile, certfile and check_hostname parameters (#94173)
Remove the keyfile, certfile and check_hostname parameters,
deprecated since Python 3.6, in modules: ftplib, http.client,
imaplib, poplib and smtplib. Use the context parameter (ssl_context
in imaplib) instead.

Parameters following the removed parameters become keyword-only
parameters.

ftplib: Remove the FTP_TLS.ssl_version class attribute: use the
context parameter instead.
2022-11-03 18:32:25 +01:00
Victor Stinner a60ddd31be
gh-98401: Invalid escape sequences emits SyntaxWarning (#99011)
A backslash-character pair that is not a valid escape sequence now
generates a SyntaxWarning, instead of DeprecationWarning.  For
example, re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an
invalid escape sequence), use raw strings for regular expression:
re.compile(r"\d+\.\d+"). In a future Python version, SyntaxError will
eventually be raised, instead of SyntaxWarning.

Octal escapes with value larger than 0o377 (ex: "\477"), deprecated
in Python 3.11, now produce a SyntaxWarning, instead of
DeprecationWarning. In a future Python version they will be
eventually a SyntaxError.

codecs.escape_decode() and codecs.unicode_escape_decode() are left
unchanged: they still emit DeprecationWarning.

* The parser only emits SyntaxWarning for Python 3.12 (feature
  version), and still emits DeprecationWarning on older Python
  versions.
* Fix SyntaxWarning by using raw strings in Tools/c-analyzer/ and
  wasm_build.py.
2022-11-03 17:53:25 +01:00
Shantanu 1208037246
gh-83004: Clean up refleak in _io initialisation (#98840) 2022-11-03 07:29:11 -07:00
serge-sans-paille 8c4de57de9
gh-98948: Remove obsolete readelf dependency (#98949)
This got introduced in commit 5884449539
to determine if readline is already linked against curses or tinfo in
the setup.py, which is no longer present.
2022-11-03 14:31:37 +01:00
Mark Shannon f4adb97506
GH-96793: Implement PEP 479 in bytecode. (GH-99006)
* Handle converting StopIteration to RuntimeError in bytecode.

* Add custom instruction for converting StopIteration into RuntimeError.
2022-11-03 11:38:51 +00:00
Serhiy Storchaka e9ac890c02
gh-98740: Fix validation of conditional expressions in RE (GH-98764)
In very rare circumstances the JUMP opcode could be confused with the
argument of the opcode in the "then" part which doesn't end with the
JUMP opcode. This led to incorrect detection of the final JUMP opcode
and incorrect calculation of the size of the subexpression.

NOTE: Changed return value of functions _validate_inner() and
_validate_charset() in Modules/_sre/sre.c.  Now they return 0 on success,
-1 on failure, and 1 if the last op is JUMP (which usually is a failure).
Previously they returned 1 on success and 0 on failure.
2022-11-03 09:23:46 +02:00
Guido van Rossum 41bc101dd6
GH-98831: "Generate" the interpreter (#98830)
The switch cases (really TARGET(opcode) macros) have been moved from ceval.c to generated_cases.c.h. That file is generated from instruction definitions in bytecodes.c (which impersonates a C file so the C code it contains can be edited without custom support in e.g. VS Code).

The code generator lives in Tools/cases_generator (it has a README.md explaining how it works). The DSL used to describe the instructions is a work in progress, described in https://github.com/faster-cpython/ideas/blob/main/3.12/interpreter_definition.md.

This is surely a work-in-progress. An easy next step could be auto-generating super-instructions.

**IMPORTANT: Merge Conflicts**

If you get a merge conflict for instruction implementations in ceval.c, your best bet is to port your changes to bytecodes.c. That file looks almost the same as the original cases, except instead of `TARGET(NAME)` it uses `inst(NAME)`, and the trailing `DISPATCH()` call is omitted (the code generator adds it automatically).
2022-11-02 21:31:26 -07:00
Nikita Sobolev 2cfcaf5af6
gh-98999: Raise `ValueError` in `_pyio` on closed buffers (gh-99009) 2022-11-03 12:03:12 +09:00
Brett Cannon 22bab74c8f
gh-97731: Specify the full path to the docs for `make docclean` (GH-98982)
Specify the full path to the docs for `make docclean`
This is to have `make clean` not error out on cross-builds.
2022-11-02 12:34:22 -07:00
Chaim Sanders e3ec272f57
gh-98415: Fix uuid.getnode() ifconfig implementation (#98423)
The uuid.getnode() function has multiple implementations, tested sequentially.
The ifconfig implementation was incorrect and always failed: fix it.

In practice, functions of libuuid library are preferred, if available:
uuid_generate_time_safe(), uuid_create() or uuid_generate_time().

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2022-11-02 19:41:20 +01:00
Steve Dower 3d889dc0a0
gh-98790: When DLLs directory is missing on Windows, assume executable_dir contains PYD files instead (GH-98936) 2022-11-02 18:38:40 +00:00
Serhiy Storchaka f520d720f6
gh-99016: Make build scripts compatible with Python 3.8 (GH-99017) 2022-11-02 20:30:09 +02:00
Brandt Bucher 276d77724f
GH-98686: Quicken everything (GH-98687) 2022-11-02 10:42:57 -07:00
Jelle Zijlstra f7241aaf6f
gh-98989: configure: add 3.11 to list of Pythons (#98988)
Closes #98989

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-11-02 10:05:42 -07:00
Victor Stinner c76db37c0d
gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.

* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
2022-11-02 15:37:40 +01:00
Brett Cannon 9711265182
gh-98925: Lower marshal recursion depth for WASI (GH-98938)
For wasmtime 2.0, the stack depth cost is 6% higher. This causes the default max `marshal` recursion depth to blow the stack.

As the default marshal depth is 2000 and Windows is set to 1000, split the difference and choose 1500 for WASI to be safe.
2022-11-01 15:51:05 -07:00
Zachary Ware c0859743d9
gh-98689: Update Windows builds to zlib v1.2.13 (GH-98968) 2022-11-01 13:02:51 -05:00
Pablo Galindo Salgado 395d4285bf
gh-98931: Improve error message when the user types 'import x from y' instead of 'from y import x' (#98932) 2022-11-01 13:01:20 +00:00
Serhiy Storchaka 0e15c31c7e
gh-98852: Fix subscription of type aliases (GH-98920)
Fix subscription of type aliases containing bare generic types or types
like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int],
where A is a generic type, and T is a type variable.
2022-11-01 09:33:09 +02:00
Jelle Zijlstra 5cf317ade1
gh-98658: Add __class_getitem__ to array.array (#98661)
Closes #98658
2022-10-31 21:10:18 -07:00
Kumar Aditya ab57505070
GH-98897: fix memory leak if `math.dist` raises exception (GH-98898) 2022-10-31 21:18:32 -05:00
Steve Dower 88297e2a8a
gh-98692: Enable treating shebang lines as executables in py.exe launcher (GH-98732) 2022-10-31 21:05:50 +00:00
Eric Snow 4702552885
gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)
Previously, the optional restrictions on subinterpreters were: disallow fork, subprocess, and threads.  By default, we were disallowing all three for "isolated" interpreters.  We always allowed all three for the main interpreter and those created through the legacy `Py_NewInterpreter()` API.

Those settings were a bit conservative, so here we've adjusted the optional restrictions to: fork, exec, threads, and daemon threads.  The default for "isolated" interpreters disables fork, exec, and daemon threads.  Regular threads are allowed by default.  We continue always allowing everything For the main interpreter and the legacy API.

In the code, we add `_PyInterpreterConfig.allow_exec` and  `_PyInterpreterConfig.allow_daemon_threads`.  We also add `Py_RTFLAGS_DAEMON_THREADS` and `Py_RTFLAGS_EXEC`.
2022-10-31 12:35:54 -07:00
David Hewitt e98923c0be
gh-98410: move getbufferproc and releasebufferproc to buffer.h (#31158)
This adds them to the Limited API.
2022-10-31 15:01:32 +01:00
Batuhan Taskaya a41de32942
gh-98878: Use builtins from the bound frame when offering a suggestion (#98880) 2022-10-31 13:27:13 +00:00
Irit Katriel 39448adc9d
gh-98811: use full source location to simplify __future__ imports error checking. This also fixes an incorrect error offset. (GH-98812) 2022-10-31 13:08:03 +00:00
Shantanu 29f98b46b7
gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143) 2022-10-31 08:31:01 -04:00
Jason R. Coombs 018b2483c4
gh-97966: Update uname docs to clarify the special nature of the platform attribute and to indicate when it became late-bound. (#97972) 2022-10-30 11:53:58 -04:00
Nick Coghlan 05e48865be
gh-96853: Restore test coverage for Py_Initialize(Ex) (GH-98212)
* As most of `test_embed` now uses `Py_InitializeFromConfig`, add
  a specific test case to cover `Py_Initialize` (and `Py_InitializeEx`)
* Rename `_testembed` init helper to clarify the API used
* Add a `PyConfig_Clear` call in `Py_InitializeEx` to make
  the code more obviously correct (it already didn't leak as
  none of the dynamically allocated config fields were being
  populated, but it's clearer if the wrappers follow the
  documented API usage guidelines)
2022-10-30 22:01:30 +10:00
Nikita Sobolev 76f989dc3e
gh-98783: Fix crashes when `str` subclasses are used in `_PyUnicode_Equal` (#98806) 2022-10-30 02:23:20 -04:00
Charlie Zhao 3ac8c0ab6e
gh-98793: Fix typecheck in `overlapped.c` (#98835)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-29 21:34:46 -07:00
Kumar Aditya 9bdec0aa45
GH-90352: fix _SelectorDatagramTransport to inherit from DatagramTransport (#98844) 2022-10-29 09:43:42 -07:00
Batuhan Taskaya c0f2a5ef91
gh-98744: Prevent column-level decoding crashes on traceback module (#98824) 2022-10-29 13:28:20 +01:00
domragusa e089f23bbb
gh-84538: add strict argument to pathlib.PurePath.relative_to (GH-19813)
By default, :meth:`pathlib.PurePath.relative_to` doesn't deal with paths that are not a direct prefix of the other, raising an exception in that instance. This change adds a *walk_up* parameter that can be set to allow for using ``..`` to calculate the relative path.

example:
```
>>> p = PurePosixPath('/etc/passwd')
>>> p.relative_to('/etc')
PurePosixPath('passwd')
>>> p.relative_to('/usr')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pathlib.py", line 940, in relative_to
    raise ValueError(error_message.format(str(self), str(formatted)))
ValueError: '/etc/passwd' does not start with '/usr'
>>> p.relative_to('/usr', strict=False)
PurePosixPath('../etc/passwd')
```


https://bugs.python.org/issue40358

Automerge-Triggered-By: GH:brettcannon
2022-10-28 16:20:14 -07:00
Gareth Rees 7ee3aca00a
gh-92452: Avoid race in initialization of sysconfig._CONFIG_VARS
Co-authored-by: Filipe Laíns <lains@riseup.net>
2022-10-28 19:17:04 +01:00
Miro Hrončok 5a8c4b9464
gh-98776: Fix make regen-test-levenshtein for out-of-tree builds (GH-98779)
Fixes https://github.com/python/cpython/issues/98776

Automerge-Triggered-By: GH:erlend-aasland
2022-10-28 04:31:33 -07:00
Steve Dower 25811d9010
gh-98745: Allow py.exe launcher to install 3.11 by default and 3.12 on request (GH-98780) 2022-10-28 10:12:22 +01:00
noah-weingarden 0346eddbe9
gh-98624 Add mutex to unittest.mock.NonCallableMock (#98688)
* Added lock to NonCallableMock in unittest.mock

* Add blurb

* Nitpick blurb

* Edit comment based on @Jason-Y-Z's review

* Add link to GH issue
2022-10-28 08:51:18 +01:00
Shaun Walbridge 3e07f827b3
gh-98739: Update libexpat from 2.4.9 to 2.5.0 (#98742)
* Update libexpat from 2.4.9 to 2.5.0 to address CVE-2022-43680.

Co-authored-by: Shaun Walbridge <shaun.walbridge@gmail.com>
2022-10-27 13:45:12 -07:00
Mark Shannon 22863df7ca
GH-96793: Change `FOR_ITER` to not pop the iterator on exhaustion. (GH-96801)
Change FOR_ITER to have the same stack effect regardless of whether it branches or not.
Performance is unchanged as FOR_ITER (and specialized forms jump over the cleanup code).
2022-10-27 11:55:03 +01:00
Wenzel Jakob e60892f9db
gh-98586: Add vector call APIs to the Limited API (GH-98587)
Expose the facilities for making vector calls through Python's limited API.
2022-10-27 11:45:42 +02:00
Ken Jin 8a755423eb
gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times (GH-98704)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-27 10:37:12 +08:00
Eric Snow f32369480d
gh-98608: Change _Py_NewInterpreter() to _Py_NewInterpreterFromConfig() (gh-98609)
(see https://github.com/python/cpython/issues/98608)

This change does the following:

1. change the argument to a new `_PyInterpreterConfig` struct
2. rename the function to `_Py_NewInterpreterFromConfig()`, inspired by `Py_InitializeFromConfig()` (takes a `_PyInterpreterConfig`  instead of `isolated_subinterpreter`)
3. split up the boolean `isolated_subinterpreter` into the corresponding multiple granular settings
   * allow_fork
   * allow_subprocess
   * allow_threads
4. add `PyInterpreterState.feature_flags` to store those settings
5. add a function for checking if a feature is enabled on an opaque `PyInterpreterState *`
6. drop `PyConfig._isolated_interpreter`

The existing default (see `Py_NewInterpeter()` and `Py_Initialize*()`) allows fork, subprocess, and threads and the optional "isolated" interpreter (see the `_xxsubinterpreters` module) disables all three.  None of that changes here; the defaults are preserved.

Note that the given `_PyInterpreterConfig` will not be used outside `_Py_NewInterpreterFromConfig()`, nor preserved.  This contrasts with how `PyConfig` is currently preserved, used, and even modified outside `Py_InitializeFromConfig()`.  I'd rather just avoid that mess from the start for `_PyInterpreterConfig`.  We can preserve it later if we find an actual need.

This change allows us to follow up with a number of improvements (e.g. stop disallowing subprocess and support disallowing exec instead).

(Note that this PR adds "private" symbols.  We'll probably make them public, and add docs, in a separate change.)
2022-10-26 11:16:30 -06:00
Nikita Sobolev 9495360c72
gh-98713: Use `@cpython_only` for a test that fails on PyPy (#98714)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-10-26 14:15:39 +01:00
Neil Schemenauer de6981680b
gh-90716: add _pylong.py module (#96673)
Add Python implementations of certain longobject.c functions. These use
asymptotically faster algorithms that can be used for operations on
integers with many digits. In those cases, the performance overhead of
the Python implementation is not significant since the asymptotic
behavior is what dominates runtime. Functions provided by this module
should be considered private and not part of any public API.

Co-author: Tim Peters <tim.peters@gmail.com>
Co-author: Mark Dickinson <dickinsm@gmail.com>
Co-author: Bjorn Martinsson
2022-10-25 22:00:50 -07:00
Stanley 268129a74f
docs: Change links to label refs (#98454)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-10-25 20:26:28 -07:00
Pablo Galindo Salgado 7cfbb49fcd
gh-91058: Add error suggestions to 'import from' import errors (#98305) 2022-10-25 23:56:59 +01:00
Erlend E. Aasland 0c84593275
gh-94328: Update Windows installer to use SQLite 3.39.4 (#98640) 2022-10-25 20:27:21 +02:00
Matthew Rahtz cb95cc24ef
GH-87390: Add remaining tests for PEP 646 (#98267)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2022-10-25 07:44:30 -07:00
James Gerity d91de288e7
gh-93696: Locate frozen module source with __file__ (#93697)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-25 06:22:53 -07:00
Erlend E. Aasland 8aa1e994a5
gh-94328: Update macOS installer to use SQLite 3.39.4. (#98639) 2022-10-25 12:49:44 +02:00
Thomas Wouters 4ae1a0ecaf Python 3.12.0a1 2022-10-25 00:08:22 +02:00
Kumar Aditya ad1dc3ebb6
GH-89237: fix hang in proactor `subprocess.wait_closed()` (#98572) 2022-10-24 13:21:42 -07:00
Serhiy Storchaka 75a6fadf36
gh-91524: Speed up the regular expression substitution (#91525)
Functions re.sub() and re.subn() and corresponding re.Pattern methods
are now 2-3 times faster for replacement strings containing group references.

Closes #91524

Primarily authored by serhiy-storchaka Serhiy Storchaka
Minor-cleanups-by: Gregory P. Smith [Google] <greg@krypto.org>
2022-10-23 15:57:30 -07:00
Ikko Ashimine f7f55a5b9e
Fix typo in news entry (#98361)
ouput -> output
2022-10-22 12:59:12 +01:00
Victor Stinner ec1f6f5f13
gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
2022-10-21 16:21:36 +02:00
Carl Meyer 82ccbf69a8
gh-91051: allow setting a callback hook on PyType_Modified (GH-97875) 2022-10-21 14:41:51 +01:00
Gregory P. Smith 49f61068f4
gh-97514: Don't use Linux abstract sockets for multiprocessing (#98501)
Linux abstract sockets are insecure as they lack any form of filesystem
permissions so their use allows anyone on the system to inject code into
the process.

This removes the default preference for abstract sockets in
multiprocessing introduced in Python 3.9+ via
https://github.com/python/cpython/pull/18866 while fixing
https://github.com/python/cpython/issues/84031.

Explicit use of an abstract socket by a user now generates a
RuntimeWarning.  If we choose to keep this warning, it should be
backported to the 3.7 and 3.8 branches.
2022-10-20 15:30:09 -07:00
Dennis Sweeney 39bc70e267
gh-97912: Avoid quadratic behavior when adding LOAD_FAST_CHECK (GH-97952)
* The compiler analyzes the usage of the first 64 local variables all at once using bit masks.

* Local variables beyond the first 64 are only partially analyzed, achieving linear time.
2022-10-20 18:27:41 -04:00
Ben Kallus 6f15ca8c7a
gh-96035: Make urllib.parse.urlparse reject non-numeric ports (#98273)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-20 14:00:56 -07:00
Irit Katriel 4ec9ed8fde
gh-98461: Fix source location in comprehensions bytecode (GH-98464) 2022-10-20 16:58:37 +01:00
Steve Dower e48f9b2b7e
gh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments (GH-98462) 2022-10-20 14:53:38 +01:00
Noam Cohen a371a7e03e
gh-95023: Added os.setns and os.unshare functions (#95046)
Added os.setns and os.unshare to easily switch between namespaces
on Linux.

Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-10-20 11:08:54 +02:00
Dong-hee Na 4156b2fc13
gh-98374: Suppress ImportError for invalid query for help() command. (gh-98450) 2022-10-20 10:56:21 +09:00
chgnrdv 1f369ad07f
gh-98354: Add unicode check for 'name' attribute in _imp_create_builtin (GH-98412)
Fixes #98354
2022-10-19 17:25:10 -07:00
Victor Stinner a8fe4bbd6b
gh-98257: Make _PyEval_SetTrace() reentrant (#98258)
Make sys.setprofile() and sys.settrace() functions reentrant.  They
can no long fail with: RuntimeError("Cannot install a trace function
while another trace function is being installed").

Make _PyEval_SetTrace() and _PyEval_SetProfile() functions reentrant,
rather than detecting and rejecting reentrant calls. Only delete the
reference to function arguments once the new function is fully set,
when a reentrant call is safe. Call also _PySys_Audit() earlier.
2022-10-20 00:31:47 +02:00
Steve Dower 4bd63f66cd
gh-98414: py.exe launcher does not use defaults for -V:company/ option (GH-98460) 2022-10-19 23:00:09 +01:00
Hugo van Kemenade 50553004fe
Docs: Bump sphinx-lint and fix unbalanced inline literal markup (#98441)
Bump sphinx-lint and fix unbalanced inline literal markup
2022-10-19 14:00:28 +02:00
Jack Hindmarch b6e59d76c0
gh-92886: Replace assertion statements in `handlers.BaseHandler` to support running with optimizations (`-O`) (GH-93231) 2022-10-19 11:38:59 +01:00
Jack Hindmarch a3be874334
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `_test_multiprocessing.py` (GH-93233) 2022-10-19 11:07:07 +01:00
Jack Hindmarch 602ea40d89
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_py_compile.py` (GH-93235) 2022-10-19 11:05:08 +01:00
Irit Katriel 9be05df399
gh-98398: Fix source locations for 'assert' bytecode (GH-98405) 2022-10-19 10:48:50 +01:00
Serhiy Storchaka e4ec8de6fa
gh-97928: Fix handling options starting with "-" in tkinter.Text.count() (GH-98436)
Previously they were silently ignored. Now they are errors.
2022-10-19 12:30:14 +03:00
Irit Katriel c051d55ddb
gh-98390: Fix source locations of boolean sub-expressions (GH-98396) 2022-10-18 17:18:38 +01:00
Jack Hindmarch debacd9ad5
gh-92886: Fixing tests that fail when running with optimizations (`-O`) in `test_sys_settrace.py` (GH-93234) 2022-10-18 16:59:05 +01:00
Victor Stinner db03c8066a
gh-98393: os module reject bytes-like, only accept bytes (#98394)
The os module and the PyUnicode_FSDecoder() function no longer accept
bytes-like paths, like bytearray and memoryview types: only the exact
bytes type is accepted for bytes strings.
2022-10-18 17:52:31 +02:00
Paul Moore 9da5215000
gh-98331: Update bundled pip to 22.3 (#98332) 2022-10-18 15:48:14 +01:00
Raymond Hettinger de3ece769a
GH-98363: Add itertools.batched() (GH-98364) 2022-10-17 18:53:45 -05:00
Victor Stinner 1863302d61
gh-97669: Create Tools/build/ directory (#97963)
Create Tools/build/ directory. Move the following scripts from
Tools/scripts/ to Tools/build/:

* check_extension_modules.py
* deepfreeze.py
* freeze_modules.py
* generate_global_objects.py
* generate_levenshtein_examples.py
* generate_opcode_h.py
* generate_re_casefix.py
* generate_sre_constants.py
* generate_stdlib_module_names.py
* generate_token.py
* parse_html5_entities.py
* smelly.py
* stable_abi.py
* umarshal.py
* update_file.py
* verify_ensurepip_wheels.py

Update references to these scripts.
2022-10-17 12:01:00 +02:00
Ruben Vorderman eae7dad402
gh-95534: Improve gzip reading speed by 10% (#97664)
Change summary:
+ There is now a `gzip.READ_BUFFER_SIZE` constant that is 128KB. Other programs that read in 128KB chunks: pigz and cat. So this seems best practice among good programs. Also it is faster than 8 kb chunks.
+ a zlib._ZlibDecompressor was added. This is the _bz2.BZ2Decompressor ported to zlib. Since the zlib.Decompress object is better for in-memory decompression, the _ZlibDecompressor is hidden. It only makes sense in file decompression, and that is already implemented now in the gzip library. No need to bother the users with this.
+ The ZlibDecompressor uses the older Cpython arrange_output_buffer functions, as those are faster and more appropriate for the use case. 
+ GzipFile.read has been optimized. There is no longer a `unconsumed_tail` member to write back to padded file. This is instead handled by the ZlibDecompressor itself, which has an internal buffer. `_add_read_data` has been inlined, as it was just two calls.

EDIT: While I am adding improvements anyway, I figured I could add another one-liner optimization now to the python -m gzip application. That read chunks in io.DEFAULT_BUFFER_SIZE previously, but has been updated now to use READ_BUFFER_SIZE chunks.
2022-10-16 19:10:58 -07:00
Jason R. Coombs cea910ebf1
gh-97930: Merge with importlib_resources 5.9 (GH-97929)
* Merge with importlib_resources 5.9

* Update changelog
2022-10-16 15:00:39 -04:00
Joannah Nanjekye 5c9302d03a
gh-85525: Remove extra row in doc (#98337)
* remove extra row

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-10-16 13:43:31 -04:00
Terry Jan Reedy 35fa5d5e7f
gh-97527: IDLE - fix buggy macosx patch (#98313)
#97530 fixed IDLE tests possibly crashing on a Mac without a GUI.
But it resulted in IDLE not starting in 3.10.8, 3.12.0a1, and
Microsoft Python 3.10.2288.0 when test/* is not installed.
After this patch, test.* is only imported when testing on Mac.
2022-10-16 10:23:11 -04:00
Vinay Sajip f6b1e4048d
gh-98307: Add docstring and documentation for SysLogHandler.createSocket (GH-98319)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-10-16 09:15:46 +01:00
Kumar Aditya 660f10248b
GH-94597: Deprecate child watcher getters and setters (#98215)
This is the next step for deprecating child watchers.

Until we've removed the API completely we have to use it, so this PR is mostly suppressing a lot of warnings when using the API internally.

Once the child watcher API is totally removed, the two child watcher implementations we actually use and need (Pidfd and Thread) will be turned into internal helpers.
2022-10-15 16:09:30 -07:00
Pablo Galindo Salgado bb56dead33
gh-98254: Include stdlib module names in error messages for NameErrors (#98255) 2022-10-15 23:13:33 +01:00
Jakub Kuczys 120b4ab2b6
gh-95731: Fix module docstring extraction in pygettext (#95732) 2022-10-15 07:57:53 -07:00
Steve Dower 2fe44f728a
gh-98251: Allow venv to pass along PYTHON* variables to pip and ensurepip when they do not impact path resolution (GH-98259) 2022-10-14 16:58:54 +01:00
Tony Solomonik b863b9cd4b
Bpo-41246: IOCP Proactor avoid callback code duplication (#21399)
Use the same callback function for overlapped operations recv, recv_into, recvfrom, sendto, send, and sendfile inside IocpProactor.
2022-10-13 11:05:16 -07:00
Christoph Hamsen c9ed0327a9
bpo-46364: Use sockets for stdin of asyncio only on AIX (#30596)
Signed-off-by: Christoph Hamsen <hamsen.christoph@posteo.de>
Co-authored-by: July Tikhonov <july.tikh@gmail.com>
2022-10-13 09:11:15 -07:00
Victor Stinner d4b9166385
gh-98178: syslog() is not thread-safe on macOS (#98213)
On macOS, fix a crash in syslog.syslog() in multi-threaded
applications. On macOS, the libc syslog() function is not
thread-safe, so syslog.syslog() no longer releases the GIL to call
it.
2022-10-13 13:34:55 +02:00
Julien Palard 4067c6d7fe
gh-86404: Doc: Drop now unused make suspicious and rstlint. (GH-98179)
They have been replaced by
[sphinx-lint](https://github.com/sphinx-contrib/sphinx-lint).
2022-10-11 15:31:33 +02:00
Ken Jin b399115ef1
gh-95756: Lazily created cached co_* attrs (GH-97791) 2022-10-11 11:26:08 +08:00
Shantanu f871e9a7bb
gh-44098: Release the GIL during mmap on Unix (GH-98146)
This seems pretty straightforward. The issue mentions other calls in mmapmodule that we could release the GIL on, but those are in methods where we'd need to be careful to ensure that something sensible happens if those are called concurrently. In prior art, note that #12073 released the GIL for munmap.  In a toy benchmark, I see the speedup you'd expect from doing this.

Automerge-Triggered-By: GH:gvanrossum
2022-10-10 15:14:31 -07:00
Matthias Görgens 553d3c1017
gh-96821: Fix undefined behaviour in `audioop.c` (#96923)
* gh-96821: Fix undefined behaviour in `audioop.c`

Left-shifting negative numbers is undefined behaviour.

Fortunately, multiplication works just as well, is defined behaviour,
and gets compiled to the same machine code as before by optimizing
compilers.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-10-10 17:12:29 +01:00
Carl Meyer ad817cd5c4
bpo-43564: preserve original exception in args of FTP URLError (#24938)
* bpo-43564: preserve original error in args of FTP URLError

* Add NEWS blurb

Co-authored-by: Carl Meyer <carljm@instagram.com>
2022-10-09 18:59:07 -07:00
Kumar Aditya d8765284f3
GH-94597: deprecate `SafeChildWatcher`, `FastChildWatcher` and `MultiLoopChildWatcher` child watchers (#98089) 2022-10-08 13:52:19 -07:00
Joannah Nanjekye 4ed00be98f
gh-68686: Retire eptag ptag scripts (#98064)
* Retire eptag ptag scripts

* 📜🤖 Added by blurb_it.

* fix news entry error

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-10-08 07:57:47 -07:00
Pablo Galindo Salgado 83eb827247
gh-97922: Run the GC only on eval breaker (#97920) 2022-10-08 07:57:09 -07:00
Kumar Aditya 8ba9378b16
GH-98023: Change default child watcher to PidfdChildWatcher on supported systems (#98024) 2022-10-07 17:29:09 -07:00
Thomas Grainger 3d8b224547
GH-94182: Run the PidfdChildWatcher on the running loop (#94184)
There is no reason for this watcher to be attached to any particular loop.
This should make it safe to use regardless of the lifetime of the event loop running in the main thread
(relative to other loops).

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-07 17:24:01 -07:00
Shantanu cb4615fd43
gh-90085: Remove vestigial -t and -c timeit options (#94941)
See bpo-28240. The functionality was removed in 3d7feb9ac2.
The options had been deprecated since Python 3.3
2022-10-07 15:38:20 -07:00
Frazer McLean f4f8133387
GH-83901: Improve Signature.bind error message for missing keyword-only params (#95347)
Fixes GH-83901
2022-10-07 15:24:17 -07:00
Jelle Zijlstra 0f111f53c1
gh-96073: fix backticks in NEWS entry (GH-98056)
Automerge-Triggered-By: GH:JelleZijlstra
2022-10-07 14:44:56 -07:00
Lysandros Nikolaou 3de08ce8c1
gh-97997: Add col_offset field to tokenizer and use that for AST nodes (#98000) 2022-10-07 14:38:35 -07:00
Serhiy Storchaka c11b667a1d
gh-96346: Use double caching for re._compile() (#96347) 2022-10-07 12:21:42 -07:00
Noam Cohen 2a168355f0
gh-97646: Change `.js` and `.mjs` files mimetype to conform to RFC 9239 (#97934) 2022-10-07 12:00:53 -07:00
Anh71me d5fea01d9d
GH-96073: Fix wild replacement in inspect.formatannotation (#96074)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-07 11:23:06 -07:00
Nikita Sobolev 24a6645894
gh-97955: Migrate `zoneinfo` to Argument Clinic (#97958) 2022-10-07 11:06:23 -07:00
Nikita Sobolev 83cbe84dc2
gh-64373: Convert `_functools` to Argument Clinic (#96640) 2022-10-07 10:36:40 -07:00
Nikita Sobolev 5ba4875aec
gh-96415: Remove `types._cell_factory` from a module namespace (#96416)
Closes #96415
2022-10-07 10:27:14 -07:00
Barry Warsaw 13d4489142
gh-86298: Ensure that __loader__ and __spec__.loader agree in warnings.warn_explicit() (GH-97803)
In `_warnings.c`, in the C equivalent of `warnings.warn_explicit()`, if the module globals are given (and not None), the warning will attempt to get the source line for the issued warning.  To do this, it needs the module's loader.

Previously, it would only look up `__loader__` in the module globals.  In https://github.com/python/cpython/issues/86298 we want to defer to the `__spec__.loader` if available.

The first step on this journey is to check that `loader == __spec__.loader` and issue another warning if it is not.  This commit does that.

Since this is a PoC, only manual testing for now.

```python
# /tmp/foo.py
import warnings

import bar

warnings.warn_explicit(
    'warning!',
    RuntimeWarning,
    'bar.py', 2,
    module='bar knee',
    module_globals=bar.__dict__,
    )
```

```python
# /tmp/bar.py
import sys
import os
import pathlib

# __loader__ = pathlib.Path()
```

Then running this: `./python.exe -Wdefault /tmp/foo.py`

Produces:

```
bar.py:2: RuntimeWarning: warning!
  import os
```

Uncomment the `__loader__ = ` line in `bar.py` and try it again:

```
sys:1: ImportWarning: Module bar; __loader__ != __spec__.loader (<_frozen_importlib_external.SourceFileLoader object at 0x109f7dfa0> != PosixPath('.'))
bar.py:2: RuntimeWarning: warning!
  import os
```

Automerge-Triggered-By: GH:warsaw
2022-10-06 19:32:53 -07:00
Gregory P. Smith 27369ef56f
gh-82874: Convert remaining importlib format uses to f-str. (#98005)
f-yes
2022-10-06 18:27:51 -07:00
Hugo van Kemenade fa2d43e518
Docs: Fix backtick errors found by sphinx-lint (#97998)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2022-10-06 18:01:30 -07:00
Nikita Sobolev 27025e158c
gh-97850: Remove deprecated functions from `importlib.utils` (#97898)
* gh-97850: Remove deprecated functions from `importlib.utils`

* Rebase and remove `set_package` from diff
2022-10-06 17:57:10 -07:00
Guido van Rossum 09de8d7aaf
GH-90985: Revert "Deprecate passing a message into cancel()" (#97999)
Reason: we were too hasty in deprecating this.
We shouldn't deprecate it before we have a replacement.
2022-10-06 17:30:27 -07:00
Tiger c46a423a52
bpo-35540 dataclasses.asdict now supports defaultdict fields (gh-32056) 2022-10-06 17:11:59 -07:00
Carl Meyer a4b7794887
GH-91052: Add C API for watching dictionaries (GH-31787) 2022-10-07 01:08:00 +01:00
Gregory P. Smith 683ab85955
bpo-38693: Use f-strings instead of str.format() within importlib (#17058)
This is a small performance improvement, especially for one or two hot
places such as _handle_fromlist() that are called a lot and the
.format() method was being used just to join two strings with a dot.

Otherwise it is merely a readability improvement.

We keep `_ERR_MSG` and `_ERR_MSG_PREFIX` as those may be used elsewhere for canonical looking error messages.
2022-10-06 16:43:16 -07:00
Brandt Bucher 21a2d9ff55
GH-97002: Prevent `_PyInterpreterFrame`s from backing more than one `PyFrameObject` (GH-97996) 2022-10-07 00:20:01 +01:00
Lysandros Nikolaou cbf0afd8a1
gh-97973: Return all necessary information from the tokenizer (GH-97984)
Right now, the tokenizer only returns type and two pointers to the start and end of the token.
This PR modifies the tokenizer to return the type and set all of the necessary information,
so that the parser does not have to this.
2022-10-06 16:07:17 -07:00
Dong-hee Na b9d2e81716
fixes gh-96078: os.sched_yield release the GIL while calling sched_yield(2). (gh-97965) 2022-10-06 15:57:37 -07:00
Brett Cannon e1c4d56fdd
gh-65961: Do not rely solely on `__cached__` (GH-97990)
Make sure `__spec__.cached` (at minimum) can be used.
2022-10-06 15:40:22 -07:00
Jason R. Coombs 8af04cdef2
gh-97781: Apply changes from importlib_metadata 5. (GH-97785)
* gh-97781: Apply changes from importlib_metadata 5.

* Apply changes from upstream

* Apply changes from upstream.
2022-10-06 15:25:24 -04:00
Terry Jan Reedy 2b5f1360ea
gh-86482: Document assignment expression need for ()s (#23291)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-10-06 12:24:17 -07:00
larryhastings 6bfb0be804
gh-97943: PyFunction_GetAnnotations should return a borrowed reference. (#97949) 2022-10-06 12:23:20 -07:00
Ned Deily 6d0a0191a4
gh-97897: Prevent os.mkfifo and os.mknod segfaults with macOS 13 SDK (GH-97944)
The macOS 13 SDK includes support for the `mkfifoat` and `mknodat` system calls.
 Using the `dir_fd` option with either `os.mkfifo` or `os.mknod` could result in a
 segfault if cpython is built with the macOS 13 SDK but run on an earlier
 version of macOS. Prevent this by adding runtime support for detection of
 these system calls ("weaklinking") as is done for other newer syscalls on
 macOS.
2022-10-06 09:11:47 -07:00
Ethan Furman b44372e03c
gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528) 2022-10-05 15:25:55 -07:00
Brett Cannon c206e53bb7
gh-65961: Raise `DeprecationWarning` when `__package__` differs from `__spec__.parent` (#97879)
Also remove `importlib.util.set_package()` which was already slated for removal.

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2022-10-05 15:00:45 -07:00
Barry Warsaw 5dc3599135
gh-97850: Remove all known instances of module_repr() (#97876)
Remove all known instances of module_repr()
2022-10-05 11:42:26 -07:00
Tshepang Mbambo 815008a3a5
I changed my surname early this year (#96671)
* I recently changed my name

* Update ACKS
2022-10-05 11:16:45 -07:00
Adam Turner 0031e62973
gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (#97768)
:c:type:`<C type>` -> :c:expr:`<C type>`

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-10-05 11:01:14 -07:00
Pieter Eendebak aeb28f5130
gh-91539: improve performance of get_proxies_environment (#91566)
* improve performance of get_proxies_environment when there are many environment variables

* 📜🤖 Added by blurb_it.

* fix case of short env name

* fix formatting

* fix whitespace

* whitespace

* Update Lib/urllib/request.py

Co-authored-by: Carl Meyer <carl@oddbird.net>

* Update Lib/urllib/request.py

Co-authored-by: Carl Meyer <carl@oddbird.net>

* Update Lib/urllib/request.py

Co-authored-by: Carl Meyer <carl@oddbird.net>

* Update Lib/urllib/request.py

Co-authored-by: Carl Meyer <carl@oddbird.net>

* whitespace

* Update Misc/NEWS.d/next/Library/2022-04-15-11-29-38.gh-issue-91539.7WgVuA.rst

Co-authored-by: Carl Meyer <carl@oddbird.net>

* Update Lib/urllib/request.py

Co-authored-by: Carl Meyer <carl@oddbird.net>

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2022-10-05 10:57:52 -07:00
Kumar Aditya 7015e13797
gh-88050: Fix asyncio subprocess to kill process cleanly when process is blocked (#32073) 2022-10-05 10:15:31 -07:00
Serhiy Storchaka 77f0249308
gh-95196: Disable incorrect pickling of the C implemented classmethod descriptors (GH-96383) 2022-10-05 14:21:16 +03:00
Serhiy Storchaka e3ef400be7
gh-74696: Pass root_dir to custom archivers which support it (GH-94251)
Co-authored-by: Éric <merwok@netwok.org>
2022-10-05 12:48:59 +03:00
Guido van Rossum 8079bef56f
GH-96704: Add {Task,Handle}.get_context(), use it in call_exception_handler() (#96756)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-04 23:49:10 -07:00
andrei kulakov db64fb9bbe
gh-97825: fix AttributeError when calling subprocess.check_output(input=None) with encoding or errors args (#97826)
* fix AttributeError, add unit test
2022-10-04 17:47:49 -07:00
Mark Shannon 76449350b3
GH-91079: Decouple C stack overflow checks from Python recursion checks. (GH-96510) 2022-10-05 01:34:03 +01:00
Brandt Bucher 0ff8fd6583
GH-97779: Ensure that *all* frame objects are backed by "complete" frames (GH-97845) 2022-10-04 17:30:03 -07:00
Nikita Sobolev c3648f4e4a
gh-97837: Change deprecation warning message in `unittest` (#97838) 2022-10-04 17:29:18 -07:00
Adam Turner 6b3d4db02e
gh-93738: Documentation C syntax (:c:type: to :c:expr:, misc. cases) (#97775)
* :c:type: to :c:expr:

* Update Doc/whatsnew/2.4.rst
2022-10-04 16:32:27 -07:00
Ev2geny 743453a554
gh-58451: Add optional delete_on_close parameter to NamedTemporaryFile (GH-97015) 2022-10-04 23:37:33 +01:00
Łukasz Langa bbc7cd649a
gh-97008: Add a Python implementation of AttributeError and NameError suggestions (#97022)
Relevant tests moved from test_exceptions to test_traceback to be able to
compare both implementations.

Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
2022-10-04 15:31:16 -07:00
Nikita Sobolev 4f380db1a5
gh-96142: add missing params to `dataclass._DataclassParams` (gh-96382) 2022-10-04 09:53:28 -07:00
Victor Stinner 116fa62c6e
gh-97670: Remove sys.getdxp() and analyze_dxp.py script (#97671)
Remove the sys.getdxp() function and the Tools/scripts/analyze_dxp.py
script. DXP stands for "dynamic execution pairs". They were related
to DYNAMIC_EXECUTION_PROFILE and DXPAIRS macros which have been
removed in Python 3.11. Python can now be built with "./configure
--enable-pystats" to gather statistics on Python opcodes.
2022-10-04 15:28:57 +02:00
William Woodruff 6e53308829
Adjust stable ABI internal documentation (GH-96896)
I was perusing this file, and noticed that this part of the documentation is slightly out of date: the `struct` items in this TOML file currently contain `struct_abi_kind` members, which distinguish between the different types of ABI compatibility described in the comment.

I've updated the comment to reflect this.
2022-10-04 06:05:53 -07:00
Victor Stinner 6cbbc26a73
gh-97669: Remove outdated example scripts (#97675)
Remove outdated example scripts of the Tools/scripts/ directory. A
copy can be found in the old-demos project:
https://github.com/gvanrossum/old-demos

Removed scripts (39):

* byext.py
* byteyears.py
* cleanfuture.py
* copytime.py
* crlf.py
* db2pickle.py
* dutree.doc
* dutree.py
* find-uname.py
* find_recursionlimit.py
* finddiv.py
* findlinksto.py
* findnocoding.py
* fixcid.py
* fixdiv.py
* fixheader.py
* fixnotice.py
* fixps.py
* get-remote-certificate.py
* google.py
* highlight.py
* ifdef.py
* import_diagnostics.py
* lfcr.py
* linktree.py
* lll.py
* mailerdaemon.py
* make_ctype.py
* mkreal.py
* objgraph.py
* pdeps.py
* pickle2db.py
* pindent.py
* pysource.py
* reindent-rst.py
* rgrep.py
* suff.py
* texi2html.py
* which.py

Changes:

* Remove test_fixcid, test_lll, test_pdeps and test_pindent
  of test.test_tools.
* Remove get-remote-certificate.py changelog entry, since the script
  was removed.

Note: there is a copy of crlf.py in Lib/test/test_lib2to3/data/.
2022-10-04 10:49:00 +02:00
Koki Saito 27e59afa2a
gh-97816: Remove unused variables in `mutliprocessing.managers.Server` (#97817)
Remove unused local variables.
2022-10-03 22:29:17 -07:00
Nikita Sobolev 06016845dc
gh-97639: Remove `tokenize.NL` check from `tabnanny` (#97640)
* gh-97639: Remove `tokenize.NL` check from `tabnanny`

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2022-10-03 17:41:29 -07:00
Brandt Bucher 93fcc1f413
GH-97752: Clear the `previous` member of newly-created generator/coroutine frames (GH-97795) 2022-10-04 00:36:52 +01:00
larryhastings 00b5a08c80
gh-97799: use inspect.get_annotations in dataclass (#97800)
dataclass used to get the annotations on a class object using
cls.__dict__.get('__annotations__').  Now that it always imports
inspect, it can use inspect.get_annotations, which is modern
best practice for coping with annotations.
2022-10-03 15:46:09 -07:00
Gregory P. Smith b0f89cb431
gh-96512: Move int_max_str_digits setting to PyConfig (#96944)
It had to live as a global outside of PyConfig for stable ABI reasons in
the pre-3.12 backports.

This removes the `_Py_global_config_int_max_str_digits` and gets rid of
the equivalent field in the internal `struct _is PyInterpreterState` as
code can just use the existing nested config struct within that.

Adds tests to verify unique settings and configs in subinterpreters.
2022-10-03 13:55:45 -07:00
Victor Stinner 64fe343717
gh-97681: Remove Tools/demo/ directory (#97682)
Remove the Tools/demo/ directory which contained old demo scripts. A
copy can be found in the old-demos project:
https://github.com/gvanrossum/old-demos

Remove the following old demo scripts:

* beer.py
* eiffel.py
* hanoi.py
* life.py
* markov.py
* mcast.py
* queens.py
* redemo.py
* rpython.py
* rpythond.py
* sortvisu.py
* spreadsheet.py
* vector.py

Changes:

* Remove a reference to the redemo.py script in the regex howto
  documentation.
* Remove a reference to the removed Tools/demo/ directory in the
  curses documentation.
* Update PC/layout/ to remove the reference to Tools/demo/ directory.
2022-10-03 17:09:02 +02:00
Serhiy Storchaka 0ee9619a4c
gh-97728: Argument Clinic: Fix uninitialized variable in the Py_UNICODE converter (GH-97729)
It affects function os.system() on Windows and Windows-specific modules
winreg, _winapi, _overlapped, and _msi.
2022-10-03 10:42:54 +03:00
C.A.M. Gerlach 9148c0d893
gh-97740: Fix bang in Sphinx C domain ref target syntax (#97741)
* gh-97740: Fix bang in Sphinx C domain ref target syntax

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

* Add NEWS entry for C domain bang fix

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2022-10-03 05:51:22 +02:00
Koki Saito 19ca114645
gh-96819: multiprocessing.resource_tracker: check if length of pipe write <= 512 (#96890)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-10-02 17:41:01 -07:00
Ofey Chan d639438609
gh-97591: In `Exception.__setstate__()` acquire strong references before calling `tp_hash` slot (#97700) 2022-10-01 20:57:17 -07:00
Gregory P. Smith 8baef8ae36
gh-95588: Drop the safety claim from `ast.literal_eval` docs. (#95919)
It was never really safe and this claim conflicts directly with the big warning in the docs about it being able to crash the interpreter.
2022-10-01 17:55:40 -07:00
Guido van Rossum 63780f4599
GH-97592: Fix crash in C remove_done_callback due to evil code (#97660)
Evil code could cause fut_callbacks to be cleared when PyObject_RichCompareBool is called.
2022-09-30 12:57:09 -07:00
Guido van Rossum e9d63760fe
GH-96827: Don't touch closed loops from executor threads (#96837)
* When chaining futures, skip callback if loop closed.
* When shutting down an executor, don't wake a closed loop.
2022-09-30 12:55:40 -07:00
Victor Stinner 9f2f1dd131
gh-94526: getpath_dirname() no longer encodes the path (#97645)
Fix the Python path configuration used to initialized sys.path at
Python startup. Paths are no longer encoded to UTF-8/strict to avoid
encoding errors if it contains surrogate characters (bytes paths are
decoded with the surrogateescape error handler).

getpath_basename() and getpath_dirname() functions no longer encode
the path to UTF-8/strict, but work directly on Unicode strings. These
functions now use PyUnicode_FindChar() and PyUnicode_Substring() on
the Unicode path, rather than strrchr() on the encoded bytes string.
2022-09-30 14:58:30 +02:00
Steve Dower ff54dd96cb
gh-90989: Install Windows launcher per-user, and clarify some installer text (GH-97655) 2022-09-30 10:29:31 +01:00
Steve Dower 73942e475c
gh-97649: The Tools directory is no longer installed on Windows (GH-97653) 2022-09-30 10:25:00 +01:00
Eddie Hebert 86a3be207d
Use SyntaxError invalid range in tutorial introduction example (GH-93031)
Use output from a 3.10+ REPL, showing invalid range, for the
SyntaxError examples in the tutorial introduction page.

Automerge-Triggered-By: GH:iritkatriel
2022-09-30 01:59:46 -07:00
Ofey Chan 83a3de4e06
gh-96348: Deprecate the 3-arg signature of coroutine.throw and generator.throw (GH-96428) 2022-09-30 09:43:02 +01:00
Shin-myoung-serp 4652093e1b
gh-91212: Fixed flickering when the tracer is turned off (#95129)
Fixed flickering when the tracer is turned off.
2022-09-28 23:40:51 -07:00
Victor Stinner 83a0f44ffd
gh-97612: Fix shell injection in get-remote-certificate.py (#97613)
Fix a shell code injection vulnerability in the
get-remote-certificate.py example script. The script no longer uses a
shell to run "openssl" commands. Issue reported and initial fix by
Caleb Shortt.

Remove the Windows code path to send "quit" on stdin to the "openssl
s_client" command: use DEVNULL on all platforms instead.

Co-authored-by: Caleb Shortt <caleb@rgauge.com>
2022-09-29 01:17:27 +02:00
Victor Stinner a5f092f3c4
gh-97616: list_resize() checks for integer overflow (#97617)
Fix multiplying a list by an integer (list *= int): detect the
integer overflow when the new allocated length is close to the
maximum size.  Issue reported by Jordan Limor.

list_resize() now checks for integer overflow before multiplying the
new allocated length by the list item size (sizeof(PyObject*)).
2022-09-29 00:07:07 +02:00
Kumar Aditya 575a253b5c
GH-82448: Add thread timeout for loop.shutdown_default_executor (#97561)
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
2022-09-28 10:39:42 -07:00
LiarPrincess 0c1d7a06ed
bpo-47243: Duplicate entry in 'Objects/unicodetype_db.h' (GH-32376)
Fix for duplicate 1st entry in 'Objects/unicodetype_db.h':

```c
/* a list of unique character type descriptors */
const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0}, <--- HERE
    {0, 0, 0, 0, 0, 32},
    {0, 0, 0, 0, 0, 48},
    …
```

https://bugs.python.org/issue47243

Automerge-Triggered-By: GH:isidentical
2022-09-28 06:57:14 -07:00
Pablo Galindo Salgado aab01e3524
gh-96670: Raise SyntaxError when parsing NULL bytes (#97594) 2022-09-27 23:23:42 +01:00
Serhiy Storchaka adbed2d542
gh-73588: Fix generation of the default name of tkinter.Checkbutton. (GH-97547)
Previously, checkbuttons in different parent widgets could have the same
short name and share the same state if arguments "name" and "variable" are
not specified. Now they are globally unique.
2022-09-27 14:05:05 +03:00
Cyker Way 68c46ae68b
gh-97545: Make Semaphore run faster. (#97549) 2022-09-26 16:38:00 -07:00
Victor Stinner 41351662bc
gh-96848: Fix -X int_max_str_digits option parsing (#96988)
Fix command line parsing: reject "-X int_max_str_digits" option with
no value (invalid) when the PYTHONINTMAXSTRDIGITS environment
variable is set to a valid limit.
2022-09-26 17:20:08 +02:00
Kumar Aditya c8c0afc713
GH-78724: Initialize struct.Struct in __new__ (GH-94532)
Closes https://github.com/python/cpython/issues/75960
Closes https://github.com/python/cpython/issues/78724
2022-09-25 14:32:48 +01:00
Mark Dickinson f5f047aa62
gh-96735: Fix undefined behaviour in struct unpacking functions (#96739)
This PR fixes undefined behaviour in the struct module unpacking support functions `bu_longlong`, `lu_longlong`, `bu_int` and `lu_int`; thanks to @kumaraditya303 for finding these.

The fix is to accumulate the bytes in an unsigned integer type instead of a signed integer type, then to convert to the appropriate signed type. In cases where the width matches, that conversion will typically be compiled away to a no-op.
(Evidence from Godbolt: https://godbolt.org/z/5zvxodj64 .)

To make the conversions efficient, I've specialised the relevant functions for their output size: for `bu_longlong` and `lu_longlong`, this only entails checking that the output size is indeed `8`. But `bu_int` and `lu_int` were used for format sizes `2` and `4` - I've split those into two separate functions each.

No tests, because all of the affected cases are already exercised by the test suite.
2022-09-25 10:55:33 +01:00
Oscar Benjamin 817fa28f81
gh-90716: Refactor PyLong_FromString to separate concerns (GH-96808)
This is a preliminary PR to refactor `PyLong_FromString` which is currently quite messy and has spaghetti like code that mixes up different concerns as well as duplicating logic.

In particular:

- `PyLong_FromString` now only handles sign, base and prefix detection and calls a new function `long_from_string_base` to parse the main body of the string.
- The `long_from_string_base` function handles all string validation and then calls `long_from_binary_base` or a new function `long_from_non_binary_base` to construct the actual `PyLong`.
- The existing `long_from_binary_base` function is simplified by factoring duplicated logic to `long_from_string_base`.
- The new function `long_from_non_binary_base` factors out much of the code from `PyLong_FromString` including in particular the quadratic algorithm reffered to in gh-95778 so that this can be seen separately from unrelated concerns such as string validation.
2022-09-25 10:09:50 +01:00
Serhiy Storchaka ea4be278fa
gh-97519: Synchronize links in other copies of HISTORY OF THE SOFTWARE (GH-97520)
HTTP links in the "HISTORY OF THE SOFTWARE" section of Doc/license.rst
were converted to HTTPS in f62ff97f31.
But there were other copies of these links, which were left HTTP links.
2022-09-25 11:25:24 +03:00
Steve Dower f1cca801f5
gh-96965: Update Windows release to libffi 3.4.3 (GH-97512) 2022-09-23 16:07:53 +01:00
Dong-hee Na 83d84e67cd
gh-96761: Fix build process of the clang compiler for _bootstrap_python (gh-96945)
Co-authored-by: Matthias Goergens <matthias.goergens@gmail.com>
2022-09-23 11:00:44 +09:00
Kumar Aditya 282edd7b2a
GH-85760: Fix race in calling process_exited callback too early (#97009) 2022-09-22 09:43:47 -07:00
Cyker Way 24e0379624
gh-90155: Fix bug in asyncio.Semaphore and strengthen FIFO guarantee (#93222)
The main problem was that an unluckily timed task cancellation could cause
the semaphore to be stuck. There were also doubts about strict FIFO ordering
of tasks allowed to pass.

The Semaphore implementation was rewritten to be more similar to Lock.
Many tests for edge cases (including cancellation) were added.
2022-09-22 09:34:45 -07:00
Brandt Bucher 8fd2c3b75b
GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97003) 2022-09-22 09:16:52 -07:00
Dong-hee Na 10e3d398c3
gh-97005: Update libexpat from 2.4.7 to 2.4.9 (gh-97006)
Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2022-09-22 21:25:05 +09:00
Brandt Bucher dfc73b5724
GH-95921: Fix positions for some chained comparisons (GH-96968) 2022-09-20 12:22:24 -07:00
Gregory P. Smith 34de67c094
gh-96512: Update int_max_str docs to say 3.11 (#96942)
It was unknown if it'd be before 3.11.0 when creating the original
changes.  It's in 3.11rc2, so 3.11 it is.
2022-09-19 16:43:11 -07:00
Gregory P. Smith e61ca22431
gh-95865: Further reduce quote_from_bytes memory consumption (#96860)
on large input values.  Based on Dennis Sweeney's chunking idea.
2022-09-19 16:06:25 -07:00
Victor Stinner 04f4977f50
gh-96387: take_gil() resets drop request before exit (#96869)
At Python exit, sometimes a thread holding the GIL can wait forever
for a thread (usually a daemon thread) which requested to drop the
GIL, whereas the thread already exited. To fix the race condition,
the thread which requested the GIL drop now resets its request before
exiting.

take_gil() now calls RESET_GIL_DROP_REQUEST() before
PyThread_exit_thread() if it called SET_GIL_DROP_REQUEST to fix a
race condition with drop_gil().

Issue discovered and analyzed by Mingliang ZHAO.
2022-09-20 00:13:56 +02:00
Brandt Bucher c10e33ac11
GH-96864: Check for error between line and opcode events (GH-96880) 2022-09-19 14:02:24 -07:00
Matthias Görgens cbdeda8ce7
gh-96821: Fix undefined behaviour in `_testcapimodule.c` (GH-96915)
* gh-96821: Assert for demonstrating undefined behaviour

* Fix UB

Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
2022-09-19 15:59:13 +08:00
Guido van Rossum 487135a396
Revert "gh-87079: Warn on unintended signal wakeup fd override in `asyncio` (#96807)" (#96898)
This reverts commit 0587810698.
Reason: This broke buildbots (some warnings added by that commit are turned to errors in the SSL buildbot).
Repro:  ./python Lib/test/ssltests.py
2022-09-17 14:12:45 -07:00
Lysandros Nikolaou 7e36abbb78
gh-91210: Improve error message when non-default param follows default (GH-95933)
- Improve error message when parameter without a default follows one with a default
- Show same error message when positional-only params precede the default/non-default sequence
2022-09-17 10:09:28 -07:00
Michel Hidalgo 0587810698
gh-87079: Warn on unintended signal wakeup fd override in `asyncio` (#96807)
Warn on loop initialization, when setting the wakeup fd disturbs a previously set wakeup fd, and on loop closing, when upon resetting the wakeup fd, we find it has been changed by someone else.
2022-09-17 08:07:54 -07:00
Christian Heimes 0b62964b04
gh-96883: browser: include concurrent.futures (GH-96886) 2022-09-17 13:23:39 +02:00
Victor Stinner e841ffc915
gh-95778: Mention sys.set_int_max_str_digits() in error message (#96874)
When ValueError is raised if an integer is larger than the limit,
mention sys.set_int_max_str_digits() in the error message.
2022-09-16 20:04:37 +02:00
Serhiy Storchaka 426d72e7dd
gh-96052: codeop: fix handling compiler warnings in incomplete input (GH-96132)
Previously codeop.compile_command() emitted compiler warnings (SyntaxWarning or
DeprecationWarning) and raised a SyntaxError for incomplete input containing
a potentially incorrect code. Now it always returns None for incomplete input
without emitting any warnings.
2022-09-16 17:37:30 +03:00
Dong-hee Na e47b96c44f
gh-89536: Use ThinLTO policy if possible (gh-96766) 2022-09-16 19:40:05 +09:00
adphrost a41ed975e8
GH-91049: Introduce set vectorcall field API for PyFunctionObject (GH-92257)
Co-authored-by: Andrew Frost <adfrost@fb.com>
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
2022-09-15 16:42:37 +01:00
Nikita Sobolev e37ac5fbb6
gh-96751: Remove dead code from `CALL_FUNCTION_EX` opcode (GH-96752) 2022-09-15 10:33:13 +01:00
Ruan Comelli 8e9a37dde4
Fix type annotation of `pstats.FunctionProfile.ncalls` (#96741)
* fix: annotate `pstats.FunctionProfile.ncalls` as `str`

This change aligns the type annotation of `pstats.FunctionProfile.ncalls` with its runtime type.
2022-09-14 18:33:43 -07:00
Brandt Bucher a83fdf2563
GH-90997: Improve inline cache performance for MSVC (GH-96781) 2022-09-14 17:05:04 -07:00
Yusuke Kadowaki 92338f8f19
gh-77171 Support WAVE_FORMAT_EXTENSIBLE in the wave module (GH-96777)
The test file, a modified version of Lib/test/audiodata/pluck-pcm24.wav, was provided by Andrea Celletti on the bug tracker.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2022-09-14 14:34:40 +01:00
Benjamin Peterson fd1e477f53
closes gh-96734: Update to Unicode 15.0.0. (GH-96809) 2022-09-13 15:45:12 -07:00
Matthias Görgens 81e36f350b
gh-96678: Fix UB of null pointer arithmetic (GH-96782)
Automerge-Triggered-By: GH:pablogsal
2022-09-13 06:14:35 -07:00
Pablo Galindo Salgado 830a20eb32
gh-93503: Document the new tracing/profiling APIs in the What's new document (#96681)
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-09-13 13:12:15 +01:00
Mark Shannon 12c5f328d2
GH-96754: Check whether the interpreter frame is complete before creating frame object. (GH-96776) 2022-09-13 09:25:16 +01:00
adang1345 662782e95f
gh-96729: Ensure installers built with Tools/msi/buildrelease.bat have matching UUIDs with official releases (GH-96755) 2022-09-12 15:23:13 +01:00
Christian Heimes a36235d5c7
gh-84461: Omit resource mod and getresuid funcs on Emscripten (GH-96303) 2022-09-11 10:10:00 +02:00
Dong-hee Na 8d75a13fde
gh-90751: memoryview now supports half-float (#96738)
Co-authored-by: Antoine Pitrou <antoine@python.org>
2022-09-10 22:44:10 +02:00
Mark Shannon 50a70a083d
GH-96678: Fix undefined behavior in ceval.c (#96708) 2022-09-10 01:12:06 +01:00
Brandt Bucher b4954b1a9e
GH-90230: Fix warnings and failures with --enable-pystats (GH-96622) 2022-09-09 14:42:29 -07:00
Kumar Aditya 88a7f661ca
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584) 2022-09-09 12:33:40 +01:00
Nikita Sobolev 30cc1901ef
gh-96364: Fix text signatures of `__getitem__` for `list` and `dict` (GH-96365) 2022-09-09 17:37:02 +09:00
Dennis Sweeney 569ca27293
gh-96624: Fix test_dotted_but_module_not_loaded in testpatch.py (GH-96691)
* Update test_dotted_but_module_not_loaded to reflect the move of unittest.test to test.test_unittest.
2022-09-08 23:46:13 -04:00
Guido van Rossum df50938f58
GH-46412: More efficient bool() for ndbm/_gdbmmodule (#96692) 2022-09-08 19:32:40 -07:00
finefoot c06c001b30
gh-92734: Add indentation feature to reprlib.Repr (GH-92735) 2022-09-08 13:51:44 -05:00
Mark Shannon aa3b4cf779
GH-96636: Remove all uses of NOTRACE_DISPATCH (GH-96643)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2022-09-08 17:16:48 +01:00
philg314 b9634ac776
gh-96352: Set AttributeError context in _PyObject_GenericGetAttrWithDict (#96353) 2022-09-08 12:12:14 +01:00
Victor Stinner c580a81af9
gh-96652: Fix faulthandler chained signal without sigaction() (#96666)
Fix the faulthandler implementation of faulthandler.register(signal,
chain=True) if the sigaction() function is not available: don't call
the previous signal handler if it's NULL.
2022-09-08 12:20:22 +02:00
Michael Droettboom 8bc356a7dd
gh-96268: Fix loading invalid UTF-8 (#96270)
This makes tokenizer.c:valid_utf8 match stringlib/codecs.h:decode_utf8.

It also fixes an off-by-one error introduced in 3.10 for the line number when the tokenizer reports bad UTF8.
2022-09-07 14:23:54 -07:00
Charlie Zhao 3e26de3c1f
gh-94781: Fix Windows projects not cleaning intermediate and output files for frozen modules (GH-96423) 2022-09-07 21:26:53 +01:00
Steve Dower de33df27aa
gh-89545: Updates platform module to use new internal _wmi module on Windows to directly query OS properties (GH-96289) 2022-09-07 21:09:20 +01:00
Steve Dower 4114bcc9ef
gh-96577: Fixes buffer overrun in _msi module (GH-96633) 2022-09-07 18:01:35 +01:00
Raymond Hettinger 3eaf70d836
GH-96465: Cache hashes for Fraction instances (GH-96483) 2022-09-07 10:31:50 -05:00
Nikita Sobolev 2fd7246e97
gh-96641: Do not expose `KeyWrapper` in `_functoolsmodule.c` (gh-96642) 2022-09-07 20:13:07 +09:00
Michael Droettboom 05692c67c5
gh-96611: Fix error message for invalid UTF-8 in mid-multiline string (#96623) 2022-09-07 00:12:16 +01:00
Kumar Aditya 67444902a0
GH-96572: fix use after free in trace refs build mode (#96618) 2022-09-06 11:02:41 -07:00
Mark Shannon 95e271b226
GH-96612: Skip incomplete frames in tracemalloc traces. (GH-96613) 2022-09-06 17:37:47 +01:00