Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix declared in 2 places
  • Loading branch information
BobTheBuidler committed Sep 17, 2025
commit 1f3d409fe84f5a012e95ea81896cec574ade07d3
4 changes: 4 additions & 0 deletions mypyc/lib-rt/CPy.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ static inline PyObject *CPyTuple_LoadEmptyTupleConstant(void) {
return __mypyc_empty_tuple__;
}

// Shared unicode objects for method names
extern PyObject *clear_id_unicode;
extern PyObject *copy_id_unicode;

// Native object operations


Expand Down
3 changes: 1 addition & 2 deletions mypyc/lib-rt/dict_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ static PyObject *update_id_unicode = NULL;
static PyObject *keys_id_unicode = NULL;
static PyObject *values_id_unicode = NULL;
static PyObject *items_id_unicode = NULL;
static PyObject *clear_id_unicode = NULL;
static PyObject *copy_id_unicode = NULL;
// clear_id_unicode and copy_id_unicode are shared with list_ops, declared in misc_ops.c

// Dict subclasses like defaultdict override things in interesting
// ways, so we don't want to just directly use the dict methods. Not
Expand Down
7 changes: 3 additions & 4 deletions mypyc/lib-rt/list_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#define Py_TPFLAGS_SEQUENCE (1 << 5)
#endif

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

PyObject *CPyList_Build(Py_ssize_t len, ...) {
Py_ssize_t i;
Expand Down Expand Up @@ -38,7 +37,7 @@ char CPyList_Clear(PyObject *list) {
} else {
if (clear_id_unicode == NULL) {
_Py_IDENTIFIER(clear);
PyObject *clear_id_unicode = _PyUnicode_FromId(&PyId_clear);
clear_id_unicode = _PyUnicode_FromId(&PyId_clear);
if (clear_id_unicode == NULL) {
return 0;
}
Expand All @@ -57,7 +56,7 @@ PyObject *CPyList_Copy(PyObject *list) {
}
if (copy_id_unicode == NULL) {
_Py_IDENTIFIER(copy);
PyObject *copy_id_unicode = _PyUnicode_FromId(&PyId_copy);
copy_id_unicode = _PyUnicode_FromId(&PyId_copy);
if (copy_id_unicode == NULL) {
return NULL;
}
Expand Down
8 changes: 5 additions & 3 deletions mypyc/lib-rt/misc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <patchlevel.h>
#include "CPy.h"

PyObject *clear_id_unicode = NULL;
PyObject *copy_id_unicode = NULL;
static PyObject *send_id_unicode = NULL;

PyObject *CPy_GetCoro(PyObject *obj)
{
// If the type has an __await__ method, call it,
Expand All @@ -20,8 +24,6 @@ PyObject *CPy_GetCoro(PyObject *obj)
}
}

static PyObject *send_id_unicode = NULL;

PyObject *CPyIter_Send(PyObject *iter, PyObject *val)
{
// Do a send, or a next if second arg is None.
Expand All @@ -31,7 +33,7 @@ PyObject *CPyIter_Send(PyObject *iter, PyObject *val)
} else {
if (send_id_unicode == NULL) {
_Py_IDENTIFIER(send);
PyObject *send_id_unicode = _PyUnicode_FromId(&PyId_send); /* borrowed */
send_id_unicode = _PyUnicode_FromId(&PyId_send); /* borrowed */
if (send_id_unicode == NULL) {
return NULL;
}
Expand Down
Loading