Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f303639

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
bpo-33270: Intern names for all anonymous code objects (#6472)
1 parent afbbac1 commit f303639

4 files changed

Lines changed: 9 additions & 8 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Intern the names for all anonymous code objects. Patch by Zackery Spytz.

Python/compile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4145,7 +4145,7 @@ compiler_genexp(struct compiler *c, expr_ty e)
41454145
{
41464146
static identifier name;
41474147
if (!name) {
4148-
name = PyUnicode_FromString("<genexpr>");
4148+
name = PyUnicode_InternFromString("<genexpr>");
41494149
if (!name)
41504150
return 0;
41514151
}
@@ -4160,7 +4160,7 @@ compiler_listcomp(struct compiler *c, expr_ty e)
41604160
{
41614161
static identifier name;
41624162
if (!name) {
4163-
name = PyUnicode_FromString("<listcomp>");
4163+
name = PyUnicode_InternFromString("<listcomp>");
41644164
if (!name)
41654165
return 0;
41664166
}
@@ -4175,7 +4175,7 @@ compiler_setcomp(struct compiler *c, expr_ty e)
41754175
{
41764176
static identifier name;
41774177
if (!name) {
4178-
name = PyUnicode_FromString("<setcomp>");
4178+
name = PyUnicode_InternFromString("<setcomp>");
41794179
if (!name)
41804180
return 0;
41814181
}
@@ -4191,7 +4191,7 @@ compiler_dictcomp(struct compiler *c, expr_ty e)
41914191
{
41924192
static identifier name;
41934193
if (!name) {
4194-
name = PyUnicode_FromString("<dictcomp>");
4194+
name = PyUnicode_InternFromString("<dictcomp>");
41954195
if (!name)
41964196
return 0;
41974197
}

Python/importlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ const unsigned char _Py_M__importlib[] = {
561561
1,100,0,107,9,86,0,1,0,113,2,100,0,83,0,41,
562562
1,78,114,10,0,0,0,41,2,90,2,46,48,90,3,97,
563563
114,103,114,10,0,0,0,114,10,0,0,0,114,11,0,0,
564-
0,250,9,60,103,101,110,101,120,112,114,62,65,1,0,0,
564+
0,218,9,60,103,101,110,101,120,112,114,62,65,1,0,0,
565565
115,2,0,0,0,4,0,122,45,95,105,110,115,116,97,108,
566566
108,101,100,95,115,97,102,101,108,121,46,95,95,101,120,105,
567567
116,95,95,46,60,108,111,99,97,108,115,62,46,60,103,101,

Python/importlib_external.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const unsigned char _Py_M__importlib_external[] = {
132132
116,114,105,112,218,15,112,97,116,104,95,115,101,112,97,114,
133133
97,116,111,114,115,41,2,218,2,46,48,218,4,112,97,114,
134134
116,114,2,0,0,0,114,2,0,0,0,114,4,0,0,0,
135-
250,10,60,108,105,115,116,99,111,109,112,62,58,0,0,0,
135+
218,10,60,108,105,115,116,99,111,109,112,62,58,0,0,0,
136136
115,2,0,0,0,6,1,122,30,95,112,97,116,104,95,106,
137137
111,105,110,46,60,108,111,99,97,108,115,62,46,60,108,105,
138138
115,116,99,111,109,112,62,41,2,218,8,112,97,116,104,95,
@@ -1678,7 +1678,7 @@ const unsigned char _Py_M__importlib_external[] = {
16781678
2,86,0,1,0,113,2,100,1,83,0,41,2,114,186,0,
16791679
0,0,78,114,2,0,0,0,41,2,114,22,0,0,0,218,
16801680
6,115,117,102,102,105,120,41,1,218,9,102,105,108,101,95,
1681-
110,97,109,101,114,2,0,0,0,114,4,0,0,0,250,9,
1681+
110,97,109,101,114,2,0,0,0,114,4,0,0,0,218,9,
16821682
60,103,101,110,101,120,112,114,62,33,4,0,0,115,2,0,
16831683
0,0,4,1,122,49,69,120,116,101,110,115,105,111,110,70,
16841684
105,108,101,76,111,97,100,101,114,46,105,115,95,112,97,99,
@@ -2350,7 +2350,7 @@ const unsigned char _Py_M__importlib_external[] = {
23502350
0,104,0,124,0,93,12,125,1,124,1,160,0,161,0,146,
23512351
2,113,4,83,0,114,2,0,0,0,41,1,114,90,0,0,
23522352
0,41,2,114,22,0,0,0,90,2,102,110,114,2,0,0,
2353-
0,114,2,0,0,0,114,4,0,0,0,250,9,60,115,101,
2353+
0,114,2,0,0,0,114,4,0,0,0,218,9,60,115,101,
23542354
116,99,111,109,112,62,153,5,0,0,115,2,0,0,0,6,
23552355
0,122,41,70,105,108,101,70,105,110,100,101,114,46,95,102,
23562356
105,108,108,95,99,97,99,104,101,46,60,108,111,99,97,108,

0 commit comments

Comments
 (0)