Skip to content

Commit 1f3d409

Browse files
committed
fix declared in 2 places
1 parent f77f297 commit 1f3d409

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

mypyc/lib-rt/CPy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ static inline PyObject *CPyTuple_LoadEmptyTupleConstant(void) {
7474
return __mypyc_empty_tuple__;
7575
}
7676

77+
// Shared unicode objects for method names
78+
extern PyObject *clear_id_unicode;
79+
extern PyObject *copy_id_unicode;
80+
7781
// Native object operations
7882

7983

mypyc/lib-rt/dict_ops.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ static PyObject *update_id_unicode = NULL;
1515
static PyObject *keys_id_unicode = NULL;
1616
static PyObject *values_id_unicode = NULL;
1717
static PyObject *items_id_unicode = NULL;
18-
static PyObject *clear_id_unicode = NULL;
19-
static PyObject *copy_id_unicode = NULL;
18+
// clear_id_unicode and copy_id_unicode are shared with list_ops, declared in misc_ops.c
2019

2120
// Dict subclasses like defaultdict override things in interesting
2221
// ways, so we don't want to just directly use the dict methods. Not

mypyc/lib-rt/list_ops.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#define Py_TPFLAGS_SEQUENCE (1 << 5)
1010
#endif
1111

12-
static PyObject *clear_id_unicode = NULL;
13-
static PyObject *copy_id_unicode = NULL;
12+
// clear_id_unicode and copy_id_unicode are shared with dict_ops, declared in misc_ops.c
1413

1514
PyObject *CPyList_Build(Py_ssize_t len, ...) {
1615
Py_ssize_t i;
@@ -38,7 +37,7 @@ char CPyList_Clear(PyObject *list) {
3837
} else {
3938
if (clear_id_unicode == NULL) {
4039
_Py_IDENTIFIER(clear);
41-
PyObject *clear_id_unicode = _PyUnicode_FromId(&PyId_clear);
40+
clear_id_unicode = _PyUnicode_FromId(&PyId_clear);
4241
if (clear_id_unicode == NULL) {
4342
return 0;
4443
}
@@ -57,7 +56,7 @@ PyObject *CPyList_Copy(PyObject *list) {
5756
}
5857
if (copy_id_unicode == NULL) {
5958
_Py_IDENTIFIER(copy);
60-
PyObject *copy_id_unicode = _PyUnicode_FromId(&PyId_copy);
59+
copy_id_unicode = _PyUnicode_FromId(&PyId_copy);
6160
if (copy_id_unicode == NULL) {
6261
return NULL;
6362
}

mypyc/lib-rt/misc_ops.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include <patchlevel.h>
77
#include "CPy.h"
88

9+
PyObject *clear_id_unicode = NULL;
10+
PyObject *copy_id_unicode = NULL;
11+
static PyObject *send_id_unicode = NULL;
12+
913
PyObject *CPy_GetCoro(PyObject *obj)
1014
{
1115
// If the type has an __await__ method, call it,
@@ -20,8 +24,6 @@ PyObject *CPy_GetCoro(PyObject *obj)
2024
}
2125
}
2226

23-
static PyObject *send_id_unicode = NULL;
24-
2527
PyObject *CPyIter_Send(PyObject *iter, PyObject *val)
2628
{
2729
// Do a send, or a next if second arg is None.
@@ -31,7 +33,7 @@ PyObject *CPyIter_Send(PyObject *iter, PyObject *val)
3133
} else {
3234
if (send_id_unicode == NULL) {
3335
_Py_IDENTIFIER(send);
34-
PyObject *send_id_unicode = _PyUnicode_FromId(&PyId_send); /* borrowed */
36+
send_id_unicode = _PyUnicode_FromId(&PyId_send); /* borrowed */
3537
if (send_id_unicode == NULL) {
3638
return NULL;
3739
}

0 commit comments

Comments
 (0)