https://github.com/python/cpython/commit/37968845284501a536a96b9fdafab83d43dd9b9d
commit: 37968845284501a536a96b9fdafab83d43dd9b9d
branch: main
author: Victor Stinner <vstin...@python.org>
committer: vstinner <vstin...@python.org>
date: 2025-03-27T10:03:58+01:00
summary:

gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714)

For example, expression_rule() return type is 'expr_ty', whereas
_PyPegen_lookahead() uses 'void*'.

files:
M Parser/pegen.c

diff --git a/Parser/pegen.c b/Parser/pegen.c
index 592269ead31e39..75fdd467e55045 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -406,11 +406,14 @@ _PyPegen_lookahead_with_int(int positive, Token 
*(func)(Parser *, int), Parser *
     return (res != NULL) == positive;
 }
 
-int
+// gh-111178: Use _Py_NO_SANITIZE_UNDEFINED to disable sanitizer checks on
+// undefined behavior (UBsan) in this function, rather than changing 'func'
+// callback API.
+int _Py_NO_SANITIZE_UNDEFINED
 _PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p)
 {
     int mark = p->mark;
-    void *res = (void*)func(p);
+    void *res = func(p);
     p->mark = mark;
     return (res != NULL) == positive;
 }

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to