https://github.com/python/cpython/commit/996246994341c91308364f3ed018cf9b7fec9bc8
commit: 996246994341c91308364f3ed018cf9b7fec9bc8
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-03-22T10:38:47+01:00
summary:
gh-131296: fix clang-cl warning in tracemalloc.c (#131514)
Always set MAX_NFRAME to UINT16_MAX.
Avoid the complicated code which emitted a compiler warning.
files:
M Python/tracemalloc.c
diff --git a/Python/tracemalloc.c b/Python/tracemalloc.c
index 2bdb6c36bdb18d..7066a214f1065b 100644
--- a/Python/tracemalloc.c
+++ b/Python/tracemalloc.c
@@ -48,10 +48,7 @@ typedef struct tracemalloc_traceback traceback_t;
#define TRACEBACK_SIZE(NFRAME) \
(sizeof(traceback_t) + sizeof(frame_t) * (NFRAME - 1))
-/* The maximum number of frames is either:
- - The maximum number of frames we can store in `traceback_t.nframe`
- - The maximum memory size_t we can allocate */
-static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX -
sizeof(traceback_t)) / sizeof(frame_t) + 1));
+static const int MAX_NFRAME = UINT16_MAX;
#define tracemalloc_empty_traceback _PyRuntime.tracemalloc.empty_traceback
@@ -791,9 +788,9 @@ tracemalloc_deinit(void)
int
_PyTraceMalloc_Start(int max_nframe)
{
- if (max_nframe < 1 || (unsigned long) max_nframe > MAX_NFRAME) {
+ if (max_nframe < 1 || max_nframe > MAX_NFRAME) {
PyErr_Format(PyExc_ValueError,
- "the number of frames must be in range [1; %lu]",
+ "the number of frames must be in range [1; %i]",
MAX_NFRAME);
return -1;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]