mirror of https://github.com/python/cpython.git
gh-132168: Add `__class_getitem__` to `ctypes.py_object` (#132169)
This commit is contained in:
parent
0788948dcb
commit
e2476398ee
|
@ -2632,6 +2632,9 @@ These are the fundamental ctypes data types:
|
|||
Represents the C :c:expr:`PyObject *` datatype. Calling this without an
|
||||
argument creates a ``NULL`` :c:expr:`PyObject *` pointer.
|
||||
|
||||
.. versionchanged:: next
|
||||
:class:`!py_object` is now a :term:`generic type`.
|
||||
|
||||
The :mod:`!ctypes.wintypes` module provides quite some other Windows specific
|
||||
data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`, or :c:type:`!DWORD`.
|
||||
Some useful structures like :c:type:`!MSG` or :c:type:`!RECT` are also defined.
|
||||
|
|
|
@ -622,6 +622,11 @@ ctypes
|
|||
loaded by the current process.
|
||||
(Contributed by Brian Ward in :gh:`119349`.)
|
||||
|
||||
* The :class:`ctypes.py_object` type now supports subscription,
|
||||
making it a :term:`generic type`.
|
||||
(Contributed by Brian Schubert in :gh:`132168`.)
|
||||
|
||||
|
||||
datetime
|
||||
--------
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@ def __repr__(self):
|
|||
return super().__repr__()
|
||||
except ValueError:
|
||||
return "%s(<NULL>)" % type(self).__name__
|
||||
__class_getitem__ = classmethod(_types.GenericAlias)
|
||||
_check_size(py_object, "P")
|
||||
|
||||
class c_short(_SimpleCData):
|
||||
|
|
|
@ -139,7 +139,7 @@ class BaseTest(unittest.TestCase):
|
|||
DictReader, DictWriter,
|
||||
array]
|
||||
if ctypes is not None:
|
||||
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
|
||||
generic_types.extend((ctypes.Array, ctypes.LibraryLoader, ctypes.py_object))
|
||||
if ValueProxy is not None:
|
||||
generic_types.extend((ValueProxy, DictProxy, ListProxy, ApplyResult,
|
||||
MPSimpleQueue, MPQueue, MPJoinableQueue))
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
The :class:`ctypes.py_object` type now supports subscription, making it a
|
||||
:term:`generic type`.
|
Loading…
Reference in New Issue