Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3833d27

Browse files
authored
gh-105733: Soft-deprecate ctypes.ARRAY, rather than hard-deprecating it. (GH-122281)
Soft-deprecate ctypes.ARRAY, rather than hard-deprecating it.Partially reverts2211454
1 parent11ad731 commit3833d27

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

‎Doc/library/ctypes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,15 @@ Arrays and pointers
26882688
Array subclass constructors accept positional arguments, used to
26892689
initialize the elements in order.
26902690

2691+
..function::ARRAY(type, length)
2692+
2693+
Create an array.
2694+
Equivalent to ``type * length``, where *type* is a
2695+
:mod:`ctypes` data type and *length* an integer.
2696+
2697+
This function is:term:`soft deprecated` in favor of multiplication.
2698+
There are no plans to remove it.
2699+
26912700

26922701
..class::_Pointer
26932702

‎Doc/whatsnew/3.13.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,8 @@ New Deprecations
14941494
(Contributed by Hugo van Kemenade in:gh:`80480`.)
14951495

14961496
*:mod:`ctypes`: Deprecate undocumented:func:`!ctypes.SetPointerType`
1497-
and:func:`!ctypes.ARRAY` functions.
1498-
Replace ``ctypes.ARRAY(item_type, size)`` with ``item_type * size``.
1497+
function.:term:`Soft-deprecate <soft deprecated>` the:func:`ctypes.ARRAY`
1498+
function in favor of multiplication.
14991499
(Contributed by Victor Stinner in:gh:`105733`.)
15001500

15011501
*:mod:`decimal`: Deprecate non-standard format specifier "N" for

‎Lib/ctypes/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ def SetPointerType(pointer, cls):
324324
del_pointer_type_cache[id(pointer)]
325325

326326
defARRAY(typ,len):
327-
importwarnings
328-
warnings._deprecated("ctypes.ARRAY",remove=(3,15))
329327
returntyp*len
330328

331329
################################################################

‎Lib/test/test_ctypes/test_arrays.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
importctypes
22
importsys
33
importunittest
4-
importwarnings
5-
fromctypesimport (Structure,Array,sizeof,addressof,
4+
fromctypesimport (Structure,Array,ARRAY,sizeof,addressof,
65
create_string_buffer,create_unicode_buffer,
76
c_char,c_wchar,c_byte,c_ubyte,c_short,c_ushort,c_int,c_uint,
87
c_long,c_ulonglong,c_float,c_double,c_longdouble)
@@ -17,13 +16,6 @@
1716
c_long,c_ulonglong,c_float,c_double,c_longdouble
1817

1918

20-
defARRAY(*args):
21-
# ignore DeprecationWarning in tests
22-
withwarnings.catch_warnings():
23-
warnings.simplefilter('ignore',DeprecationWarning)
24-
returnctypes.ARRAY(*args)
25-
26-
2719
classArrayTestCase(unittest.TestCase):
2820
deftest_inheritance_hierarchy(self):
2921
self.assertEqual(Array.mro(), [Array,_CData,object])
@@ -275,10 +267,6 @@ def test_bpo36504_signed_int_overflow(self):
275267
deftest_large_array(self,size):
276268
c_char*size
277269

278-
deftest_deprecation(self):
279-
withself.assertWarns(DeprecationWarning):
280-
CharArray=ctypes.ARRAY(c_char,3)
281-
282270

283271
if__name__=='__main__':
284272
unittest.main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:func:`ctypes.ARRAY` is now:term:`soft deprecated`: it no longer emits deprecation
2+
warnings and is not scheduled for removal.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp