8000 Use _Py_DECLARE_STR · python/cpython@59e6fa0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59e6fa0

Browse files
committed
Use _Py_DECLARE_STR
1 parent c0b04e3 commit 59e6fa0

File tree

5 files changed

+18
-29
lines changed

5 files changed

+18
-29
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ struct _Py_global_strings {
4040
STRUCT_FOR_STR(dbl_close_br, "}}")
4141
STRUCT_FOR_STR(dbl_open_br, "{{")
4242
STRUCT_FOR_STR(dbl_percent, "%%")
43+
STRUCT_FOR_STR(defaults, ".defaults")
4344
STRUCT_FOR_STR(dot, ".")
4445
STRUCT_FOR_STR(dot_locals, ".<locals>")
4546
STRUCT_FOR_STR(empty, "")
4647
STRUCT_FOR_STR(json_decoder, "json.decoder")
48+
STRUCT_FOR_STR(kwdefaults, ".kwdefaults")
4749
STRUCT_FOR_STR(list_err, "list index out of range")
50+
STRUCT_FOR_STR(namespace, ".namespace")
4851
STRUCT_FOR_STR(newline, "\n")
4952
STRUCT_FOR_STR(open_br, "{")
5053
STRUCT_FOR_STR(percent, "%")
@@ -615,7 +618,6 @@ struct _Py_global_strings {
615618
STRUCT_FOR_ID(reducer_override)
616619
STRUCT_FOR_ID(registry)
617620
STRUCT_FOR_ID(rel_tol)
618-
STRUCT_FOR_ID(release)
619621
STRUCT_FOR_ID(reload)
620622
STRUCT_FOR_ID(repl)
621623
STRUCT_FOR_ID(replace)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/symtable.c

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,23 +1123,6 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag,
11231123
lineno, col_offset, end_lineno, end_col_offset);
11241124
}
11251125

1126-
static int
1127-
symtable_add_param(const char *name, struct symtable *st,
1128-
int lineno, int col_offset, int end_lineno, int end_col_offset)
1129-
{
1130-
PyObject *name_obj = PyUnicode_FromString(name);
1131-
if (name_obj == NULL) {
1132-
return 0;
1133-
}
1134-
if (!symtable_add_def(st, name_obj, DEF_PARAM,
1135-
lineno, col_offset, end_lineno, end_col_offset)) {
1136-
Py_DECREF(name_obj);
1137-
return 0;
1138-
}
1139-
Py_DECREF(name_obj);
1140-
return 1;
1141-
}
1142-
11431126
static int
11441127
symtable_enter_typeparam_block(struct symtable *st, identifier name,
11451128
void *ast, int has_defaults, int has_kwdefaults,
@@ -1153,20 +1136,23 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name,
11531136
}
11541137
if (current_type == ClassBlock) {
11551138
st->st_cur->ste_type_params_in_class = 1;
1156-
if (!symtable_add_param(".namespace", st,
1157-
lineno, col_offset, end_lineno, end_col_offset)) {
1139+
_Py_DECLARE_STR(namespace, ".namespace");
1140+
if (!symtable_add_def(st, &_Py_STR(namespace), DEF_PARAM,
1141+
lineno, col_offset, end_lineno, end_col_offset)) {
11581142
return 0;
11591143
}
11601144
}
11611145
if (has_defaults) {
1162-
if (!symtable_add_param(".defaults", st,
1163-
lineno, col_offset, end_lineno, end_col_offset)) {
1146+
_Py_DECLARE_STR(defaults, ".defaults");
1147+
if (!symtable_add_def(st, &_Py_STR(defaults), DEF_PARAM,
1148+
lineno, col_offset, end_lineno, end_col_offset)) {
11641149
return 0;
11651150
}
11661151
}
11671152
if (has_kwdefaults) {
1168-
if (!symtable_add_param(".kwdefaults", st,
1169-
lineno, col_offset, end_lineno, end_col_offset)) {
1153+
_Py_DECLARE_STR(kwdefaults, ".kwdefaults");
1154+
if (!symtable_add_def(st, &_Py_STR(kwdefaults), DEF_PARAM,
1155+
lineno, col_offset, end_lineno, end_col_offset)) {
11701156
return 0;
11711157
}
11721158
}

0 commit comments

Comments
 (0)
0