Skip to content

Commit fd66205

Browse files
committed
fix linker
1 parent 1f3d409 commit fd66205

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

mypyc/lib-rt/CPy.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ 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-
8177
// Native object operations
8278

8379

mypyc/lib-rt/dict_ops.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ 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-
// clear_id_unicode and copy_id_unicode are shared with list_ops, declared in misc_ops.c
18+
// dict_ prefix prevents a name conflict with list_ops
19+
static PyObject *dict_copy_id_unicode = NULL;
20+
static PyObject *dict_clear_id_unicode = NULL;
1921

2022
// Dict subclasses like defaultdict override things in interesting
2123
// ways, so we don't want to just directly use the dict methods. Not
@@ -336,14 +338,14 @@ char CPyDict_Clear(PyObject *dict) {
336338
if (PyDict_CheckExact(dict)) {
337339
PyDict_Clear(dict);
338340
} else {
339-
if (clear_id_unicode == NULL) {
341+
if (dict_clear_id_unicode == NULL) {
340342
_Py_IDENTIFIER(clear);
341-
clear_id_unicode = _PyUnicode_FromId(&PyId_clear); /* borrowed */
342-
if (clear_id_unicode == NULL) {
343+
dict_clear_id_unicode = _PyUnicode_FromId(&PyId_clear); /* borrowed */
344+
if (dict_clear_id_unicode == NULL) {
343345
return 0;
344346
}
345347
}
346-
PyObject *res = PyObject_CallMethodNoArgs(dict, clear_id_unicode);
348+
PyObject *res = PyObject_CallMethodNoArgs(dict, dict_clear_id_unicode);
347349
if (res == NULL) {
348350
return 0;
349351
}
@@ -355,14 +357,14 @@ PyObject *CPyDict_Copy(PyObject *dict) {
355357
if (PyDict_CheckExact(dict)) {
356358
return PyDict_Copy(dict);
357359
}
358-
if (copy_id_unicode == NULL) {
360+
if (dict_copy_id_unicode == NULL) {
359361
_Py_IDENTIFIER(copy);
360-
copy_id_unicode = _PyUnicode_FromId(&PyId_copy); /* borrowed */
361-
if (copy_id_unicode == NULL) {
362+
dict_copy_id_unicode = _PyUnicode_FromId(&PyId_copy); /* borrowed */
363+
if (dict_copy_id_unicode == NULL) {
362364
return NULL;
363365
}
364366
}
365-
return PyObject_CallMethodNoArgs(dict, copy_id_unicode);
367+
return PyObject_CallMethodNoArgs(dict, dict_copy_id_unicode);
366368
}
367369

368370
PyObject *CPyDict_GetKeysIter(PyObject *dict) {

mypyc/lib-rt/list_ops.c

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

12-
// clear_id_unicode and copy_id_unicode are shared with dict_ops, declared in misc_ops.c
12+
// list_ prefix prevents a name conflict with dict_ops
13+
static PyObject *list_clear_id_unicode = NULL;
14+
static PyObject *list_copy_id_unicode = NULL;
1315

1416
PyObject *CPyList_Build(Py_ssize_t len, ...) {
1517
Py_ssize_t i;
@@ -35,14 +37,14 @@ char CPyList_Clear(PyObject *list) {
3537
if (PyList_CheckExact(list)) {
3638
PyList_Clear(list);
3739
} else {
38-
if (clear_id_unicode == NULL) {
40+
if (list_clear_id_unicode == NULL) {
3941
_Py_IDENTIFIER(clear);
40-
clear_id_unicode = _PyUnicode_FromId(&PyId_clear);
41-
if (clear_id_unicode == NULL) {
42+
list_clear_id_unicode = _PyUnicode_FromId(&PyId_clear);
43+
if (list_clear_id_unicode == NULL) {
4244
return 0;
4345
}
4446
}
45-
PyObject *res = PyObject_CallMethodNoArgs(list, clear_id_unicode);
47+
PyObject *res = PyObject_CallMethodNoArgs(list, list_clear_id_unicode);
4648
if (res == NULL) {
4749
return 0;
4850
}
@@ -54,14 +56,14 @@ PyObject *CPyList_Copy(PyObject *list) {
5456
if(PyList_CheckExact(list)) {
5557
return PyList_GetSlice(list, 0, PyList_GET_SIZE(list));
5658
}
57-
if (copy_id_unicode == NULL) {
59+
if (list_copy_id_unicode == NULL) {
5860
_Py_IDENTIFIER(copy);
59-
copy_id_unicode = _PyUnicode_FromId(&PyId_copy);
60-
if (copy_id_unicode == NULL) {
61+
list_copy_id_unicode = _PyUnicode_FromId(&PyId_copy);
62+
if (list_copy_id_unicode == NULL) {
6163
return NULL;
6264
}
6365
}
64-
return PyObject_CallMethodNoArgs(list, copy_id_unicode);
66+
return PyObject_CallMethodNoArgs(list, list_copy_id_unicode);
6567
}
6668

6769
PyObject *CPyList_GetItemShort(PyObject *list, CPyTagged index) {

mypyc/lib-rt/misc_ops.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
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-
139
PyObject *CPy_GetCoro(PyObject *obj)
1410
{
1511
// If the type has an __await__ method, call it,
@@ -24,6 +20,8 @@ PyObject *CPy_GetCoro(PyObject *obj)
2420
}
2521
}
2622

23+
static PyObject *send_id_unicode = NULL;
24+
2725
PyObject *CPyIter_Send(PyObject *iter, PyObject *val)
2826
{
2927
// Do a send, or a next if second arg is None.

0 commit comments

Comments
 (0)