Commit Graph

113106 Commits

Author SHA1 Message Date
Victor Stinner 64a54e511d
gh-91719: Add pycore_opcode.h internal header file (#91906)
Move the following API from Include/opcode.h (public C API) to a new
Include/internal/pycore_opcode.h header file (internal C API):

* EXTRA_CASES
* _PyOpcode_Caches
* _PyOpcode_Deopt
* _PyOpcode_Jump
* _PyOpcode_OpName
* _PyOpcode_RelativeJump
2022-04-26 00:14:30 +02:00
Victor Stinner 20cc695286
gh-64783: Fix signal.NSIG value on FreeBSD (#91929)
Fix signal.NSIG value on FreeBSD to accept signal numbers greater
than 32, like signal.SIGRTMIN and signal.SIGRTMAX.

* Add Py_NSIG constant.
* Add pycore_signal.h internal header file.
* _Py_Sigset_Converter() now includes the range of valid signals in
  the error message.
2022-04-26 00:13:31 +02:00
Victor Stinner 61381d7da1
gh-89653: PEP 670: Functions don't cast pointers (#91697)
In the limited C API version 3.11 and newer, the following functions
no longer cast their object pointer argument with _PyObject_CAST() or
_PyObject_CAST_CONST():

* Py_REFCNT(), Py_TYPE(), Py_SIZE()
* Py_SET_REFCNT(), Py_SET_TYPE(), Py_SET_SIZE()
* Py_IS_TYPE()
* Py_INCREF(), Py_DECREF()
* Py_XINCREF(), Py_XDECREF()
* Py_NewRef(), Py_XNewRef()
* PyObject_TypeCheck()
* PyType_Check()
* PyType_CheckExact()

Split Py_DECREF() implementation in 3 versions to make the code more
readable.

Update the xxlimited.c extension, which uses the limited C API
version 3.11, to pass PyObject* to these functions.
2022-04-26 00:11:34 +02:00
David Hewitt 1cd8c29dac
gh-91880: add try/except around `signal.signal` (#91881)
Fixes gh-91880.
2022-04-25 08:56:20 -07:00
Serhiy Storchaka 54d068adfb
gh-91904: Fix setting envvar PYTHONREGRTEST_UNICODE_GUARD (GH-91905)
It always failed on non-UTF-8 locale and prevented running regrtests.
2022-04-25 17:35:14 +03:00
Jelle Zijlstra 93d280141c
gh-90633: Improve error and docs for typing.assert_never (#91720)
Closes #90633

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-04-25 06:40:18 -07:00
Christian Heimes 9ff2f12c87
gh-84461: Include _emscripten_info in pythoninfo output (GH-91907) 2022-04-25 12:58:25 +02:00
Ezio Melotti f7641a2ffe
gh-91888: add a `:gh:` role to the documentation (#91889)
* Add a new :gh:`...` role for GitHub issues.

* Fix a GitHub id to use the :gh: role.

* Add Misc/NEWS entry.

* Refactoring and rephrasing.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2022-04-25 12:05:54 +02:00
Barry Warsaw 4403320727
Rewrite audio.py to jive with image.py (#91886)
Similar to the rewrite of email/mime/image.py and associated test after the
deprecation of imghdr.py, thisrewrites email/mime/audio.py and associated
tests after the deprecation of sndhdr.py.

Closes #91885
2022-04-24 15:50:07 -07:00
Jelle Zijlstra e93d2fbdda
gh-91821: Make decimal test succeed consistently (#91825)
The test relies on precision being set to 9, but some ways of
invoking this test leave it set to 28 instead. I don't know
exactly how it happens, but setting the precision directly should
make the behavior consistent.
2022-04-24 15:02:57 -07:00
Jelle Zijlstra dd3cf124a0
gh-91491: What's New in 3.11 section for typing PEPs (#91721)
Other aspects of typing aren't covered yet; I'll do that in a
separate PR.
2022-04-24 14:13:15 -07:00
Serhiy Storchaka 090721721b
Simplify testing the warning filename (GH-91868)
The context manager result has the "filename" attribute.
2022-04-24 10:23:59 +03:00
Zac Hatfield-Dodds b4e048411f
gh-91230: Concise catch_warnings with simplefilter (#91435) 2022-04-23 17:55:22 -07:00
Brett Cannon 692e9078a1
gh-91217: deprecate spwd (#91846)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2022-04-23 14:48:17 -07:00
Serhiy Storchaka 28890427c5
RE: Pre-split the list of opcode names (GH-91859)
1. It makes them interned.
2. It allows to add comments to individual opcodes.
2022-04-23 18:49:23 +03:00
Christian Heimes 92c1037afc
gh-84461: Add --enable-wasm-pthreads and more file systems (GH-91820) 2022-04-23 14:59:33 +02:00
Serhiy Storchaka 130a8c386b
gh-91308: Simplify parsing inline flag "x" (verbose) (GH-91855) 2022-04-23 12:50:42 +03:00
Serhiy Storchaka 6b45076bd6
RE: Add more tests for inline flag "x" and re.VERBOSE (GH-91854) 2022-04-23 12:49:06 +03:00
Christian Heimes 9b5ca5405e
gh-84461: Add sys._emscripten_info, improve docs and build (gh-91781) 2022-04-23 09:52:16 +02:00
Pablo Galindo Salgado 0daa99f68b
gh-88116: Enhance the inspect frame APIs to use the extended position information (GH-91531) 2022-04-23 03:16:48 +01:00
slateny a3f2cf3ced
gh-85864: Mark positional-only args in io docs (#91683) 2022-04-22 17:30:52 -07:00
Shantanu 254aaa7981
gh-91547: Remove "Undocumented modules" page (#91682) 2022-04-22 16:01:52 -07:00
Brett Cannon e7929cba16
gh-91217: deprecate-sndhdr (#91806)
Also inline necessary functionality from `sndhdr` into `email.mime.audio` for `MIMEAudio`.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2022-04-22 15:48:03 -07:00
Géry Ogam 5576ddbbbc
bpo-46720: Add support for path-like objects to multiprocessing.set_executable for Windows (GH-31279)
This bring the API to be on a par with Unix-like systems.
2022-04-22 15:47:09 -07:00
Serhiy Storchaka f912cc0e41
gh-91575: Add a script for generating data for case-insensitive matching in re (GH-91660)
Also test that all extra cases are in BMP.
2022-04-22 21:37:46 +03:00
Serhiy Storchaka 48ec61a89a
gh-91700: Validate the group number in conditional expression in RE (GH-91702)
In expression (?(group)...) an appropriate re.error is now
raised if the group number refers to not defined group.

Previously it raised RuntimeError: invalid SRE code.
2022-04-22 19:53:10 +03:00
Serhiy Storchaka 6ccfa31421
gh-90568: Fix exception type for \N with a named sequence in RE (GH-91665)
re.error is now raised instead of TypeError.
2022-04-22 18:35:28 +03:00
Guido van Rossum 2f233fceae
gh-89279: In ceval.c, redefine some macros for speed (#32387)
Macros Py_DECREF, Py_XDECREF, Py_IS_TYPE, _Py_atomic_load_32bit_impl
and _Py_DECREF_SPECIALIZED are redefined as macros
that completely replace the inline functions of the same name.
These three came out in the top four of functions that (in MSVC)
somehow weren't inlined.

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2022-04-22 07:46:26 -07:00
Dominic Davis-Foster 9fe82d0b70
gh-91764: Mark version typing.Unpack and LiteralString were added in (#91817)
Closes GH-91764
2022-04-22 07:28:39 -07:00
Erlend Egeberg Aasland 1218061609
gh-89653: PEP 670: Amend docs (GH-91813) 2022-04-22 14:59:18 +02:00
Victor Stinner 9e146bbb7e
gh-80527: Deprecate PEP 623 Unicode functions (#91801)
Deprecate functions:

* PyUnicode_AS_DATA()
* PyUnicode_AS_UNICODE()
* PyUnicode_GET_DATA_SIZE()
* PyUnicode_GET_SIZE()

Previously, these functions were macros and so it wasn't possible to
decorate them with Py_DEPRECATED().
2022-04-22 13:05:36 +02:00
Petr Viktorin 82ec638ab7
Docs: Clarify availability of PyOS_CheckStack (GH-91816) 2022-04-22 12:44:43 +02:00
Sam Ezeh bcf14ae433
gh-91291: Accept attributes as keyword arguments in decimal.localcontext (#32242)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-21 21:27:15 -07:00
Matthew Rahtz 5e130a8da4
bpo-43224: Implement pickling of TypeVarTuples (#32119)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-21 21:22:53 -07:00
Brett Cannon 2551a6c92f
gh-91217: deprecate-pipes (GH-91779) 2022-04-21 19:28:34 -07:00
Erlend Egeberg Aasland 29afb7d2ef
gh-69093: Add indexing and slicing support to sqlite3.Blob (#91599)
Authored-by: Aviv Palivoda <palaviv@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@innova.no>
2022-04-21 18:45:16 -07:00
Inada Naoki 1317b70f89
gh-91156: Use `locale.getencoding()` instead of getpreferredencoding (GH-91732)
Co-authored-by: Victor Stinner <vstinner@python.org>
2022-04-22 10:39:24 +09:00
Victor Stinner efe7fd4170
gh-89653: Add assertions to unicodeobject.h functions (#91800) 2022-04-21 23:26:25 +02:00
Victor Stinner 636ad7b47e
gh-89653: PEP 670: Convert unicodeobject.h macros to functions (#91799)
Convert unicodeobject.h macros to static inline functions:

* PyUnicode_AS_DATA()
* PyUnicode_AS_UNICODE()
* PyUnicode_GET_DATA_SIZE()
* PyUnicode_GET_SIZE()

Static inline functions are wrapped by macros which casts arguments
with _PyObject_CAST() to prevent introducing new compiler warnings
when passing "const PyObject*".
2022-04-21 23:07:13 +02:00
Victor Stinner 364ed94092
gh-89373: _Py_Dealloc() checks tp_dealloc exception (#32357)
If Python is built in debug mode, _Py_Dealloc() now ensures that the
tp_dealloc function leaves the current exception unchanged.
2022-04-21 23:04:01 +02:00
Victor Stinner 8a4e519e78
gh-79315: Add Include/cpython/pythread.h header (#91798) 2022-04-21 23:00:42 +02:00
Victor Stinner 6f9addb5ba
gh-79315: Add Include/cpython/modsupport.h header (#91797) 2022-04-21 23:00:26 +02:00
Victor Stinner c1474fa6c6
gh-89653: PEP 670: Group deprecated API in unicodeobject.h (#91796) 2022-04-21 22:44:23 +02:00
Victor Stinner eaa85cb22f
gh-91768: C API no longer use "const PyObject*" type (#91769)
Py_REFCNT(), Py_TYPE(), Py_SIZE() and Py_IS_TYPE() functions argument
type is now "PyObject*", rather than "const PyObject*".

* Replace also "const PyObject*" with "PyObject*" in functions:

  * _Py_strhex_impl()
  * _Py_strhex_with_sep()
  * _Py_strhex_bytes_with_sep()

* Remove _PyObject_CAST_CONST() and _PyVarObject_CAST_CONST() macros.
* Py_IS_TYPE() can now use Py_TYPE() in its implementation.
2022-04-21 22:07:19 +02:00
Victor Stinner 128d624117
gh-89653: PEP 670: Convert unicodeobject.h macros to functions (#91773)
Convert unicodeobject.h macros to static inline functions:

* PyUnicode_MAX_CHAR_VALUE()
* PyUnicode_READ()
* PyUnicode_READY()
* PyUnicode_READ_CHAR()
* PyUnicode_WRITE()

Move PyUnicode_READY() after _PyUnicode_Ready(), since it uses
_PyUnicode_Ready().

Static inline functions are wrapped by macros which casts arguments
with _PyObject_CAST() and casts 'kind' arguments to "unsigned int" to
prevent introducing new compiler warnings when passing "const
PyObject*".
2022-04-21 21:53:18 +02:00
Guido van Rossum f8dc6186d1
GH-91719: Make MSVC generate somewhat faster switch code (#91718)
Apparently a switch on an 8-bit quantity where all cases are
present generates a more efficient jump (doing only one indexed
memory load instead of two).

So we make opcode and use_tracing uint8_t, and generate a macro
full of extra `case NNN:` lines for all unused opcodes.

See https://github.com/faster-cpython/ideas/issues/321#issuecomment-1103263673
2022-04-21 11:53:57 -07:00
Mark Shannon d44815cabc
GH-88116: Document that PyCodeNew is dangerous, and make PyCode_NewEmpty less dangerous. (GH-91790) 2022-04-21 19:08:36 +01:00
Mark Shannon 5974827c71
GH-88756: Update docs for PEP 523 eval function type. (GH-91788) 2022-04-21 18:14:01 +01:00
Petr Viktorin ac4ffd3be2
bpo-47169: Export PyOS_CheckStack on Windows (GH-32414) 2022-04-21 18:03:25 +02:00
Mark Shannon 944fffee89
GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)
* Stores all location info in linetable to conform to PEP 626.

* Remove column table from code objects.

* Remove end-line table from code objects.

* Document new location table format
2022-04-21 16:10:37 +01:00