[3.10] Add more const modifiers. (GH-26691). (GH-26692)
(cherry picked from commit be8b631b7a587aa781245e14c8cca32970e1be5b)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 82f840c..1941244 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -7,7 +7,7 @@
#include "string_parser.h"
PyObject *
-_PyPegen_new_type_comment(Parser *p, char *s)
+_PyPegen_new_type_comment(Parser *p, const char *s)
{
PyObject *res = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
if (res == NULL) {
@@ -26,7 +26,7 @@
if (tc == NULL) {
return a;
}
- char *bytes = PyBytes_AsString(tc->bytes);
+ const char *bytes = PyBytes_AsString(tc->bytes);
if (bytes == NULL) {
return NULL;
}
@@ -66,7 +66,7 @@
assert(t->bytes != NULL);
assert(t->type == NOTEQUAL);
- char* tok_str = PyBytes_AS_STRING(t->bytes);
+ const char* tok_str = PyBytes_AS_STRING(t->bytes);
if (p->flags & PyPARSE_BARRY_AS_BDFL && strcmp(tok_str, "<>") != 0) {
RAISE_SYNTAX_ERROR("with Barry as BDFL, use '<>' instead of '!='");
return -1;
@@ -78,7 +78,7 @@
}
PyObject *
-_PyPegen_new_identifier(Parser *p, char *n)
+_PyPegen_new_identifier(Parser *p, const char *n)
{
PyObject *id = PyUnicode_DecodeUTF8(n, strlen(n), NULL);
if (!id) {
@@ -911,7 +911,7 @@
if (t->type != NAME) {
return NULL;
}
- char *s = PyBytes_AsString(t->bytes);
+ const char *s = PyBytes_AsString(t->bytes);
if (!s) {
p->error_indicator = 1;
return NULL;
@@ -942,7 +942,7 @@
if (t == NULL) {
return NULL;
}
- char* s = PyBytes_AsString(t->bytes);
+ const char *s = PyBytes_AsString(t->bytes);
if (!s) {
p->error_indicator = 1;
return NULL;
@@ -1068,7 +1068,7 @@
return NULL;
}
- char *num_raw = PyBytes_AsString(t->bytes);
+ const char *num_raw = PyBytes_AsString(t->bytes);
if (num_raw == NULL) {
p->error_indicator = 1;
return NULL;