Skip to content

Commit c0d7480

Browse files
Merge branch 'main' into struct-AC/143672
2 parents 76907cf + a009e78 commit c0d7480

2 files changed

Lines changed: 51 additions & 18 deletions

File tree

Doc/c-api/memory.rst

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,39 @@ The following type-oriented macros are provided for convenience. Note that
293293
294294
Same as :c:func:`PyMem_Free`.
295295
296-
In addition, the following macro sets are provided for calling the Python memory
297-
allocator directly, without involving the C API functions listed above. However,
298-
note that their use does not preserve binary compatibility across Python
299-
versions and is therefore deprecated in extension modules.
300-
301-
* ``PyMem_MALLOC(size)``
302-
* ``PyMem_NEW(type, size)``
303-
* ``PyMem_REALLOC(ptr, size)``
304-
* ``PyMem_RESIZE(ptr, type, size)``
305-
* ``PyMem_FREE(ptr)``
306-
* ``PyMem_DEL(ptr)``
296+
297+
Deprecated aliases
298+
------------------
299+
300+
These are :term:`soft deprecated` aliases to existing functions and macros.
301+
They exist solely for backwards compatibility.
302+
303+
.. list-table::
304+
:widths: auto
305+
:header-rows: 1
306+
307+
* * Deprecated alias
308+
* Corresponding function or macro
309+
* * .. c:macro:: PyMem_MALLOC(size)
310+
* :c:func:`PyMem_Malloc`
311+
* * .. c:macro:: PyMem_NEW(type, size)
312+
* :c:macro:`PyMem_New`
313+
* * .. c:macro:: PyMem_REALLOC(ptr, size)
314+
* :c:func:`PyMem_Realloc`
315+
* * .. c:macro:: PyMem_RESIZE(ptr, type, size)
316+
* :c:macro:`PyMem_Resize`
317+
* * .. c:macro:: PyMem_FREE(ptr)
318+
* :c:func:`PyMem_Free`
319+
* * .. c:macro:: PyMem_DEL(ptr)
320+
* :c:func:`PyMem_Free`
321+
322+
.. versionchanged:: 3.4
323+
324+
The macros are now aliases of the corresponding functions and macros.
325+
Previously, their behavior was the same, but their use did not necessarily
326+
preserve binary compatibility across Python versions.
327+
328+
.. deprecated:: 2.0
307329
308330
309331
.. _objectinterface:

Lib/test/test_time.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,29 @@ def test_gmtime(self):
192192
# (tm_year, tm_mon, tm_mday,
193193
# tm_hour, tm_min, tm_sec,
194194
# tm_wday, tm_yday)
195-
for t, expected in (
195+
tests = [
196196
(-13262400, (1969, 7, 31, 12, 0, 0, 3, 212)),
197197
(-6177600, (1969, 10, 21, 12, 0, 0, 1, 294)),
198-
# non-leap years (pre epoch)
199-
(-2203891200, (1900, 3, 1, 0, 0, 0, 3, 60)),
200-
(-2203977600, (1900, 2, 28, 0, 0, 0, 2, 59)),
201-
(-5359564800, (1800, 3, 1, 0, 0, 0, 5, 60)),
202-
(-5359651200, (1800, 2, 28, 0, 0, 0, 4, 59)),
203198
# leap years (pre epoch)
204199
(-2077660800, (1904, 3, 1, 0, 0, 0, 1, 61)),
205200
(-2077833600, (1904, 2, 28, 0, 0, 0, 6, 59)),
206-
):
201+
]
202+
203+
try:
204+
from _testinternalcapi import SIZEOF_TIME_T
205+
except ImportError:
206+
pass
207+
else:
208+
if SIZEOF_TIME_T >= 8:
209+
tests.extend((
210+
# non-leap years (pre epoch)
211+
(-2203891200, (1900, 3, 1, 0, 0, 0, 3, 60)),
212+
(-2203977600, (1900, 2, 28, 0, 0, 0, 2, 59)),
213+
(-5359564800, (1800, 3, 1, 0, 0, 0, 5, 60)),
214+
(-5359651200, (1800, 2, 28, 0, 0, 0, 4, 59)),
215+
))
216+
217+
for t, expected in tests:
207218
with self.subTest(t=t, expected=expected):
208219
res = time.gmtime(t)
209220
self.assertEqual(tuple(res)[:8], expected, res)

0 commit comments

Comments
 (0)