Mailing List Archive

bpo-45476: Disallow using asdl_seq_GET() as l-value (GH-29866)
https://github.com/python/cpython/commit/4b97d974ecca9cce532be55410fe851eb9fdcf21
commit: 4b97d974ecca9cce532be55410fe851eb9fdcf21
branch: main
author: Victor Stinner <vstinner@python.org>
committer: vstinner <vstinner@python.org>
date: 2021-11-30T15:13:55+01:00
summary:

bpo-45476: Disallow using asdl_seq_GET() as l-value (GH-29866)

The following internal macros can not longer be used as l-value:

* asdl_seq_GET()
* asdl_seq_GET_UNTYPED()
* asdl_seq_LEN()

They are modified to use the _Py_RVALUE() macro.

files:
M Include/internal/pycore_asdl.h

diff --git a/Include/internal/pycore_asdl.h b/Include/internal/pycore_asdl.h
index d00a7f04e6d00..5b01c7a66599e 100644
--- a/Include/internal/pycore_asdl.h
+++ b/Include/internal/pycore_asdl.h
@@ -78,9 +78,9 @@ asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *a
return seq; \
}

-#define asdl_seq_GET_UNTYPED(S, I) (S)->elements[(I)]
-#define asdl_seq_GET(S, I) (S)->typed_elements[(I)]
-#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
+#define asdl_seq_GET_UNTYPED(S, I) _Py_RVALUE((S)->elements[(I)])
+#define asdl_seq_GET(S, I) _Py_RVALUE((S)->typed_elements[(I)])
+#define asdl_seq_LEN(S) _Py_RVALUE(((S) == NULL ? 0 : (S)->size))

#ifdef Py_DEBUG
# define asdl_seq_SET(S, I, V) \

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins