Commit Graph

117545 Commits

Author SHA1 Message Date
Victor Stinner e8e59ee474
gh-106084: Remove _PyObject_RealIsInstance() function (#106106)
Remove the following functions from the public C API:

* _PyObject_RealIsInstance()
* _PyObject_RealIsSubclass()
* _Py_add_one_to_index_F()
* _Py_add_one_to_index_C()

Move _PyObject_RealIsInstance() and _PyObject_RealIsSubclass() to the
internal C API (pycore_abstract.h) and no longer export their symbols
(in libpython).

Make _Py_add_one_to_index_F() and _Py_add_one_to_index_C() functions
static: no longer export them.
2023-06-26 13:38:41 +00:00
Victor Stinner 6200aaf296
gh-106084: Remove _PyObject_HasLen() function (#106103)
Remove _PyObject_HasLen() and _PySequence_IterSearch() functions from
the public C API: move them to the internal C API
(pycore_abstract.h).

No longer export these symbols (in libpython).

Remove also unused pycore_initconfig.h include in typeobject.c.
2023-06-26 13:02:43 +00:00
Victor Stinner c075a1974b
gh-105927: Deprecate PyWeakref_GetObject() function (#106006)
Deprecate PyWeakref_GetObject() and PyWeakref_GET_OBJECT() functions.
2023-06-26 12:10:53 +02:00
Gabriel Venberg dac3d389e7
gh-104527: zippapp will now avoid appending an archive to itself. (gh-106076)
zippapp will now avoid appending an archive to itself.
2023-06-26 10:09:08 +01:00
James Webber a12e8ffb49
gh-106075: add `asyncio.taskgroups.__all__` to `asyncio.__all__` (#106090)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-06-26 07:54:03 +00:00
Alex Waygood 3eeb8c8906
Improve typing docs on the type of class objects (#106081) 2023-06-26 00:13:48 -07:00
Victor Stinner 7ca871634e
gh-106084: Remove _PySequence_BytesToCharpArray() function (#106088)
Remove private _PySequence_BytesToCharpArray() and
_Py_FreeCharPArray() functions from the public C API: move these
functions from Objects/abstract.c to Modules/_posixsubprocess.c.
2023-06-26 08:30:59 +02:00
Victor Stinner 00e75a3372
gh-106084: Remove old PyObject call aliases (#106085)
Remove old aliases which were kept backwards compatibility with
Python 3.8:

* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_FastCallDict()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyVectorcall_Function()

Update code which used these aliases to use new names.
2023-06-26 08:08:12 +02:00
Alex Waygood 93a970ffbc
gh-106046: Improve error message from `os.fspath` if `__fspath__` is set to `None` (#106082) 2023-06-26 00:06:12 +01:00
Hugo van Kemenade 8c24a83737
Add end-of-file-fixer to pre-commit (#106065) 2023-06-25 04:44:23 -06:00
Erlend E. Aasland bef1c8761e
Docs: add links to 'callable' term in sqlite3 docs (#106072) 2023-06-25 02:02:59 +02:00
Gregory P. Smith 19d6511b0b
gh-106033: [docs] Improve C API GetItem & HasAttr notes. (#106047)
Use a note:: tag so that these dict and object API deficiencies show up clearly.

A caution:: tag was considered, but our current python docs rendering doesn't do much with that (no box or color change).  warning:: seemed too extreme.  note looks good.
2023-06-24 16:29:26 -07:00
Barney Gale 4a6c84fc1e
GH-104375: Use `versionchanged` to describe new arguments in pathlib docs (GH-104376) 2023-06-24 16:14:09 +01:00
chgnrdv d2cbb6e918
gh-105987: Fix reference counting issue in `_asyncio._swap_current_task` (#105989) 2023-06-24 10:53:24 +05:30
Erlend E. Aasland 4849a80dd1
gh-102251: Disable non-rerunnable test in test_import (#106013) 2023-06-24 01:34:05 +02:00
Eamon Tracey 8ef0ee4ebc
Typing docs: fix typo in annotating tuples comment (#106048) 2023-06-23 21:34:05 +01:00
Irit Katriel d8ca5a11bc
gh-105730: support more callables in ExceptionGroup.split() and subgroup() (#106035) 2023-06-23 19:47:47 +01:00
Serhiy Storchaka 1d33d53780
gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)
These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt.  They should not be
used in new code.
2023-06-23 20:10:32 +03:00
Erlend E. Aasland 41ad4dfc04
gh-105063: Disable test_peg_generator.TestCParser bco. ref leaks (#106024)
Since gh-104798 (Use setuptools in peg-generator and reenable
tests), the TestCParser test case has been producing ref leaks.
2023-06-23 19:04:17 +02:00
Serhiy Storchaka c8c162ef52
gh-106030: Miscellaneous fixes in Python/suggestions.c (GH-106031)
* PyDict_GetItem() and PyObject_HasAttr() suppress arbitrary errors and
  should not be used.
* PyUnicode_CompareWithASCIIString() only works if the second argument
  is ASCII string.
* Refleak in get_suggestions_for_name_error.
* Use of borrowed pointer after possible freeing (self).
* Add some missing error checks.
2023-06-23 19:53:27 +03:00
Alex Waygood 9499b0f138
gh-105974: Revert unintentional behaviour change for protocols with non-callable members and custom `__subclasshook__` methods (#105976) 2023-06-23 14:59:25 +00:00
Alex Waygood 968435ddb1
Typing docs: improve the guidance on annotating tuples (#106021) 2023-06-23 15:33:20 +01:00
Erlend E. Aasland 37c5c40125
gh-85136: Remove disabled remote IMAP tests (#106022)
Tests had been disabled since Jun 12, 2020 (gh-20836).
2023-06-23 13:39:50 +00:00
Mark Shannon 9339d70ac2
GH-106012: Fix monitoring of static code objects (GH-106017) 2023-06-23 13:18:29 +01:00
Alex Waygood a72683ba8e
Docs: Avoid a DeprecationWarning in `pyspecific.py` when running with Sphinx >=6.1 (#105886)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-06-23 08:58:45 +01:00
Victor Stinner 6a80664ef1
gh-105927: Remove _PyWeakref_GetWeakrefCount() (#106007)
Remove _PyWeakref_GetWeakrefCount() and _PyWeakref_ClearRef() from
the public C API: move them to the internal C API.

Refactor also _weakref_getweakrefs() code to make it more readable.
2023-06-23 03:00:56 +00:00
Victor Stinner 7b3ed5b29f
gh-105927: _ssl GET_SOCKET() uses _PyWeakref_GET_REF() (#106002) 2023-06-23 03:02:02 +02:00
Victor Stinner ee52158f20
gh-105927: PyImport_AddModule() uses _PyWeakref_GET_REF() (#106001)
It now raises an exception if sys.modules doesn't hold a strong
reference to the module.

Elaborate the comment explaining why a weak reference is used to
create a borrowed reference.
2023-06-23 01:23:08 +02:00
Victor Stinner 193a2b2eaa
gh-105922: Use PyImport_AddModuleRef() function (#105999)
Replace PyImport_AddModuleObject() + Py_XNewRef() with
PyImport_AddModuleRef() to get directly a strong reference.
2023-06-23 00:04:39 +02:00
Brandt Bucher 403a574b00
Test specialization's thread-safety (GH-105953) 2023-06-22 22:02:38 +00:00
chgnrdv cd5280367a
gh-105979: Fix exception handling in `unmarshal_frozen_code` (`Python/import.c`) (#105980) 2023-06-22 21:30:19 +00:00
Victor Stinner 46a3190fcf
gh-105927: Avoid calling PyWeakref_GET_OBJECT() (#105997)
* Replace PyWeakref_GET_OBJECT() with _PyWeakref_GET_REF().
* _sqlite/blob.c now holds a strong reference to the blob object
  while calling close_blob().
* _xidregistry_find_type() now holds a strong reference to registered
  while using it.
2023-06-22 22:31:31 +02:00
Victor Stinner c38da1e3e1
gh-105927: Add _PyWeakref_IS_DEAD() function (#105992)
* Add _PyWeakref_IS_DEAD() internal function.
* Modify is_dead_weakref() of Modules/_weakref.c and
  _pysqlite_drop_unused_cursor_references() to replace
  PyWeakref_GET_OBJECT() with _PyWeakref_IS_DEAD().
* Replace "int i" with "Py_ssize_t i" to iterate on cursors
  in _pysqlite_drop_unused_cursor_references().
2023-06-22 21:56:44 +02:00
YAMAMOTO Takashi d8f87cdf94
gh-101538: Add experimental wasi-threads build (#101537)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-22 11:26:10 -07:00
Pablo Galindo Salgado 13237a2da8
gh-98931: Add custom error messages to invalid import/from with multiple targets (#105985)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-22 15:56:40 +00:00
Barney Gale a8006706f7
GH-89812: Add `pathlib.UnsupportedOperation` (GH-105926)
This new exception type is raised instead of `NotImplementedError` when
a path operation is not supported. It can be raised from `Path.readlink()`,
`symlink_to()`, `hardlink_to()`, `owner()` and `group()`. In a future
version of pathlib, it will be raised by `AbstractPath` for these methods
and others, such as `AbstractPath.mkdir()` and `unlink()`.
2023-06-22 14:35:51 +01:00
Mark Shannon 04492cbc9a
GH-91095: Specialize calls to normal Python classes. (GH-99331) 2023-06-22 09:48:19 +01:00
Irit Katriel c01da2896a
gh-105481: refactor instr flag related code into a new InstructionFlags class (#105950) 2023-06-21 23:14:43 +00:00
Victor Stinner 18a7c86697
gh-104212: Explain how to port imp.load_source() (#105978)
Explain how to port removed imp.load_source() to importlib in What's
New in Python 3.12.
2023-06-22 00:18:31 +02:00
Irit Katriel a2392720d6
gh-84436: update docs on Py_None/Py_True/Py_False/Py_Ellipsis becoming immortal (#105195) 2023-06-21 21:13:25 +01:00
Victor Stinner 4328dc6465
gh-105927: finalize_modules_clear_weaklist() uses _PyWeakref_GET_REF() (#105971)
finalize_modules_clear_weaklist() now holds a strong reference to the
module longer than before: replace PyWeakref_GET_OBJECT() with
_PyWeakref_GET_REF().
2023-06-21 21:50:20 +02:00
Victor Stinner fc32522b08
gh-105927: type_from_ref() uses _PyWeakref_GET_REF() (#105963)
type_from_ref() now returns a strong reference to the type, instead
of a borrowed reference: replace PyWeakref_GET_OBJECT() with
_PyWeakref_GET_REF().
2023-06-21 16:35:58 +02:00
Victor Stinner 2178bbc121
gh-105927: Fix test_weakref_capi() refleak (#105966)
Test PyWeakref_GetRef(NULL) and  PyWeakref_GetObject(NULL).
2023-06-21 16:35:41 +02:00
Victor Stinner 48d107a87d
gh-105927: _ctypes use PyWeakref_GetRef() (#105964)
Rename PyDict_GetItemProxy() to _PyDict_GetItemProxy() and mark it as
static. _PyDict_GetItemProxy() now returns a strong reference,
instead of a borrowed reference: replace PyWeakref_GET_OBJECT() with
_PyWeakref_GET_REF().
2023-06-21 16:34:27 +02:00
Victor Stinner 74da6f7c9f
gh-105927: _ssl uses _PyWeakref_GET_REF() (#105965) 2023-06-21 16:33:32 +02:00
Mathieu Dupuy c5a722be5f
stdtypes.rst: remove a period (#105959) 2023-06-21 15:21:37 +01:00
Victor Stinner fb1e691e4b
gh-105927: _abc and _thread use PyWeakref_GetRef() (#105961)
Hold a strong reference on the object, rather than using a borrowed reference:
replace PyWeakref_GET_OBJECT() with PyWeakref_GetRef() and
_PyWeakref_GET_REF().

Remove assert(PyWeakref_CheckRef(localweakref)) since it's already
tested by _PyWeakref_GET_REF().
2023-06-21 15:44:25 +02:00
Sviatoslav Sydorenko eaa6702280
Use CSV-separated outputs @ get-changed-files @ CI (#105151)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-06-21 13:42:59 +03:00
Victor Stinner 9c44656feb
gh-105927: Add PyWeakref_GetRef() function (#105932)
Add tests on PyWeakref_NewRef(), PyWeakref_GetObject(),
PyWeakref_GET_OBJECT() and PyWeakref_GetRef().
2023-06-21 11:40:09 +02:00
Victor Stinner 4d140e5e06
Add Py_TYPE() to Doc/data/refcounts.dat (#105949) 2023-06-20 23:57:54 +02:00