Skip to content

Commit bc62af1

Browse files
Issue python#22570: Renamed Py_SETREF to Py_XSETREF.
1 parent aad86a6 commit bc62af1

33 files changed

Lines changed: 110 additions & 110 deletions

Include/object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,14 +833,14 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
833833
*
834834
* The safe way is:
835835
*
836-
* Py_SETREF(op, op2);
836+
* Py_XSETREF(op, op2);
837837
*
838838
* That arranges to set `op` to `op2` _before_ decref'ing, so that any code
839839
* triggered as a side-effect of `op` getting torn down no longer believes
840840
* `op` points to a valid object.
841841
*/
842842

843-
#define Py_SETREF(op, op2) \
843+
#define Py_XSETREF(op, op2) \
844844
do { \
845845
PyObject *_py_tmp = (PyObject *)(op); \
846846
(op) = (op2); \

Modules/_bsddb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ DB_associate(DBObject* self, PyObject* args, PyObject* kwargs)
16081608

16091609
/* Save a reference to the callback in the secondary DB. */
16101610
Py_XINCREF(callback);
1611-
Py_SETREF(secondaryDB->associateCallback, callback);
1611+
Py_XSETREF(secondaryDB->associateCallback, callback);
16121612
secondaryDB->primaryDBType = _DB_get_type(self);
16131613

16141614
/* PyEval_InitThreads is called here due to a quirk in python 1.5
@@ -2498,7 +2498,7 @@ DB_set_private(DBObject* self, PyObject* private_obj)
24982498
{
24992499
/* We can set the private field even if db is closed */
25002500
Py_INCREF(private_obj);
2501-
Py_SETREF(self->private_obj, private_obj);
2501+
Py_XSETREF(self->private_obj, private_obj);
25022502
RETURN_NONE();
25032503
}
25042504

@@ -6997,7 +6997,7 @@ DBEnv_set_private(DBEnvObject* self, PyObject* private_obj)
69976997
{
69986998
/* We can set the private field even if dbenv is closed */
69996999
Py_INCREF(private_obj);
7000-
Py_SETREF(self->private_obj, private_obj);
7000+
Py_XSETREF(self->private_obj, private_obj);
70017001
RETURN_NONE();
70027002
}
70037003

@@ -7251,7 +7251,7 @@ DBEnv_set_event_notify(DBEnvObject* self, PyObject* notifyFunc)
72517251
}
72527252

72537253
Py_INCREF(notifyFunc);
7254-
Py_SETREF(self->event_notifyCallback, notifyFunc);
7254+
Py_XSETREF(self->event_notifyCallback, notifyFunc);
72557255

72567256
/* This is to workaround a problem with un-initialized threads (see
72577257
comment in DB_associate) */
@@ -7410,7 +7410,7 @@ DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args)
74107410
RETURN_IF_ERR();
74117411

74127412
Py_INCREF(rep_transport);
7413-
Py_SETREF(self->rep_transport, rep_transport);
7413+
Py_XSETREF(self->rep_transport, rep_transport);
74147414
RETURN_NONE();
74157415
}
74167416

Modules/_csv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt)
277277
}
278278
else {
279279
Py_INCREF(src);
280-
Py_SETREF(*target, src);
280+
Py_XSETREF(*target, src);
281281
}
282282
}
283283
return 0;
@@ -769,7 +769,7 @@ parse_process_char(ReaderObj *self, char c)
769769
static int
770770
parse_reset(ReaderObj *self)
771771
{
772-
Py_SETREF(self->fields, PyList_New(0));
772+
Py_XSETREF(self->fields, PyList_New(0));
773773
if (self->fields == NULL)
774774
return -1;
775775
self->field_len = 0;

Modules/_ctypes/_ctypes.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt
424424
Py_DECREF((PyObject *)dict);
425425
return NULL;
426426
}
427-
Py_SETREF(result->tp_dict, (PyObject *)dict);
427+
Py_XSETREF(result->tp_dict, (PyObject *)dict);
428428
dict->format = _ctypes_alloc_format_string(NULL, "B");
429429
if (dict->format == NULL) {
430430
Py_DECREF(result);
@@ -902,7 +902,7 @@ PyCPointerType_SetProto(StgDictObject *stgdict, PyObject *proto)
902902
return -1;
903903
}
904904
Py_INCREF(proto);
905-
Py_SETREF(stgdict->proto, proto);
905+
Py_XSETREF(stgdict->proto, proto);
906906
return 0;
907907
}
908908

@@ -992,7 +992,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
992992
Py_DECREF((PyObject *)stgdict);
993993
return NULL;
994994
}
995-
Py_SETREF(result->tp_dict, (PyObject *)stgdict);
995+
Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
996996

997997
return (PyObject *)result;
998998
}
@@ -1457,7 +1457,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
14571457
Py_DECREF((PyObject *)stgdict);
14581458
return NULL;
14591459
}
1460-
Py_SETREF(result->tp_dict, (PyObject *)stgdict);
1460+
Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
14611461

14621462
/* Special case for character arrays.
14631463
A permanent annoyance: char arrays are also strings!
@@ -1880,7 +1880,7 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
18801880
Py_DECREF((PyObject *)stgdict);
18811881
return NULL;
18821882
}
1883-
Py_SETREF(result->tp_dict, (PyObject *)stgdict);
1883+
Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
18841884

18851885
return (PyObject *)result;
18861886
}
@@ -2388,7 +2388,7 @@ PyCFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
23882388
Py_DECREF((PyObject *)stgdict);
23892389
return NULL;
23902390
}
2391-
Py_SETREF(result->tp_dict, (PyObject *)stgdict);
2391+
Py_XSETREF(result->tp_dict, (PyObject *)stgdict);
23922392

23932393
if (-1 == make_funcptrtype_dict(stgdict)) {
23942394
Py_DECREF(result);
@@ -2530,7 +2530,7 @@ KeepRef(CDataObject *target, Py_ssize_t index, PyObject *keep)
25302530
}
25312531
ob = PyCData_GetContainer(target);
25322532
if (ob->b_objects == NULL || !PyDict_CheckExact(ob->b_objects)) {
2533-
Py_SETREF(ob->b_objects, keep); /* refcount consumed */
2533+
Py_XSETREF(ob->b_objects, keep); /* refcount consumed */
25342534
return 0;
25352535
}
25362536
key = unique_key(target, index);
@@ -3053,7 +3053,7 @@ PyCFuncPtr_set_errcheck(PyCFuncPtrObject *self, PyObject *ob)
30533053
return -1;
30543054
}
30553055
Py_XINCREF(ob);
3056-
Py_SETREF(self->errcheck, ob);
3056+
Py_XSETREF(self->errcheck, ob);
30573057
return 0;
30583058
}
30593059

@@ -3082,8 +3082,8 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject *self, PyObject *ob)
30823082
return -1;
30833083
}
30843084
Py_INCREF(ob);
3085-
Py_SETREF(self->restype, ob);
3086-
Py_SETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_"));
3085+
Py_XSETREF(self->restype, ob);
3086+
Py_XSETREF(self->checker, PyObject_GetAttrString(ob, "_check_retval_"));
30873087
if (self->checker == NULL)
30883088
PyErr_Clear();
30893089
return 0;
@@ -3120,9 +3120,9 @@ PyCFuncPtr_set_argtypes(PyCFuncPtrObject *self, PyObject *ob)
31203120
converters = converters_from_argtypes(ob);
31213121
if (!converters)
31223122
return -1;
3123-
Py_SETREF(self->converters, converters);
3123+
Py_XSETREF(self->converters, converters);
31243124
Py_INCREF(ob);
3125-
Py_SETREF(self->argtypes, ob);
3125+
Py_XSETREF(self->argtypes, ob);
31263126
}
31273127
return 0;
31283128
}

Modules/_curses_panel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
284284
return NULL;
285285
}
286286
Py_INCREF(temp);
287-
Py_SETREF(po->wo, temp);
287+
Py_XSETREF(po->wo, temp);
288288
Py_INCREF(Py_None);
289289
return Py_None;
290290
}

Modules/_elementtree.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ element_setattr(ElementObject* self, const char* name, PyObject* value)
15741574

15751575
if (strcmp(name, "tag") == 0) {
15761576
Py_INCREF(value);
1577-
Py_SETREF(self->tag, value);
1577+
Py_XSETREF(self->tag, value);
15781578
} else if (strcmp(name, "text") == 0) {
15791579
Py_DECREF(JOIN_OBJ(self->text));
15801580
self->text = value;
@@ -1587,7 +1587,7 @@ element_setattr(ElementObject* self, const char* name, PyObject* value)
15871587
if (!self->extra)
15881588
element_new_extra(self, NULL);
15891589
Py_INCREF(value);
1590-
Py_SETREF(self->extra->attrib, value);
1590+
Py_XSETREF(self->extra->attrib, value);
15911591
} else {
15921592
PyErr_SetString(PyExc_AttributeError, name);
15931593
return -1;
@@ -1799,10 +1799,10 @@ treebuilder_handle_start(TreeBuilderObject* self, PyObject* tag,
17991799
self->index++;
18001800

18011801
Py_INCREF(node);
1802-
Py_SETREF(self->this, (ElementObject*) node);
1802+
Py_XSETREF(self->this, (ElementObject*) node);
18031803

18041804
Py_INCREF(node);
1805-
Py_SETREF(self->last, (ElementObject*) node);
1805+
Py_XSETREF(self->last, (ElementObject*) node);
18061806

18071807
if (treebuilder_append_event(self, self->start_event_obj, node) < 0)
18081808
goto error;
@@ -2744,7 +2744,7 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args)
27442744
target = (TreeBuilderObject*) self->target;
27452745

27462746
Py_INCREF(events);
2747-
Py_SETREF(target->events, events);
2747+
Py_XSETREF(target->events, events);
27482748

27492749
/* clear out existing events */
27502750
Py_CLEAR(target->start_event_obj);
@@ -2769,18 +2769,18 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args)
27692769
Py_INCREF(item);
27702770
event = PyString_AS_STRING(item);
27712771
if (strcmp(event, "start") == 0) {
2772-
Py_SETREF(target->start_event_obj, item);
2772+
Py_XSETREF(target->start_event_obj, item);
27732773
} else if (strcmp(event, "end") == 0) {
2774-
Py_SETREF(target->end_event_obj, item);
2774+
Py_XSETREF(target->end_event_obj, item);
27752775
} else if (strcmp(event, "start-ns") == 0) {
2776-
Py_SETREF(target->start_ns_event_obj, item);
2776+
Py_XSETREF(target->start_ns_event_obj, item);
27772777
EXPAT(SetNamespaceDeclHandler)(
27782778
self->parser,
27792779
(XML_StartNamespaceDeclHandler) expat_start_ns_handler,
27802780
(XML_EndNamespaceDeclHandler) expat_end_ns_handler
27812781
);
27822782
} else if (strcmp(event, "end-ns") == 0) {
2783-
Py_SETREF(target->end_ns_event_obj, item);
2783+
Py_XSETREF(target->end_ns_event_obj, item);
27842784
EXPAT(SetNamespaceDeclHandler)(
27852785
self->parser,
27862786
(XML_StartNamespaceDeclHandler) expat_start_ns_handler,

Modules/_functoolsmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ partial_setstate(partialobject *pto, PyObject *state)
320320
else
321321
Py_INCREF(dict);
322322

323-
Py_SETREF(pto->fn, fn);
324-
Py_SETREF(pto->args, fnargs);
325-
Py_SETREF(pto->kw, kw);
326-
Py_SETREF(pto->dict, dict);
323+
Py_XSETREF(pto->fn, fn);
324+
Py_XSETREF(pto->args, fnargs);
325+
Py_XSETREF(pto->kw, kw);
326+
Py_XSETREF(pto->dict, dict);
327327
Py_RETURN_NONE;
328328
}
329329

Modules/_io/bufferedio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ _buffered_readline(buffered *self, Py_ssize_t limit)
10281028
Py_CLEAR(res);
10291029
goto end;
10301030
}
1031-
Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks));
1031+
Py_XSETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks));
10321032

10331033
end:
10341034
LEAVE_BUFFERED(self)
@@ -1264,7 +1264,7 @@ bufferedreader_init(buffered *self, PyObject *args, PyObject *kwds)
12641264
return -1;
12651265

12661266
Py_INCREF(raw);
1267-
Py_SETREF(self->raw, raw);
1267+
Py_XSETREF(self->raw, raw);
12681268
self->buffer_size = buffer_size;
12691269
self->readable = 1;
12701270
self->writable = 0;
@@ -1686,7 +1686,7 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds)
16861686
return -1;
16871687

16881688
Py_INCREF(raw);
1689-
Py_SETREF(self->raw, raw);
1689+
Py_XSETREF(self->raw, raw);
16901690
self->readable = 0;
16911691
self->writable = 1;
16921692

@@ -2342,7 +2342,7 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds)
23422342
return -1;
23432343

23442344
Py_INCREF(raw);
2345-
Py_SETREF(self->raw, raw);
2345+
Py_XSETREF(self->raw, raw);
23462346
self->buffer_size = buffer_size;
23472347
self->readable = 1;
23482348
self->writable = 1;

Modules/_io/textio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
966966
"Oi", self->decoder, (int)self->readtranslate);
967967
if (incrementalDecoder == NULL)
968968
goto error;
969-
Py_SETREF(self->decoder, incrementalDecoder);
969+
Py_XSETREF(self->decoder, incrementalDecoder);
970970
}
971971
}
972972

@@ -1346,7 +1346,7 @@ textiowrapper_write(textio *self, PyObject *args)
13461346
static void
13471347
textiowrapper_set_decoded_chars(textio *self, PyObject *chars)
13481348
{
1349-
Py_SETREF(self->decoded_chars, chars);
1349+
Py_XSETREF(self->decoded_chars, chars);
13501350
self->decoded_chars_used = 0;
13511351
}
13521352

@@ -1475,7 +1475,7 @@ textiowrapper_read_chunk(textio *self)
14751475
goto fail;
14761476
}
14771477
Py_DECREF(dec_buffer);
1478-
Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input));
1478+
Py_XSETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input));
14791479
}
14801480
Py_DECREF(input_chunk);
14811481

@@ -1575,7 +1575,7 @@ textiowrapper_read(textio *self, PyObject *args)
15751575
if (chunks != NULL) {
15761576
if (result != NULL && PyList_Append(chunks, result) < 0)
15771577
goto fail;
1578-
Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks));
1578+
Py_XSETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks));
15791579
if (result == NULL)
15801580
goto fail;
15811581
Py_CLEAR(chunks);
@@ -1832,7 +1832,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit)
18321832
if (chunks != NULL) {
18331833
if (line != NULL && PyList_Append(chunks, line) < 0)
18341834
goto error;
1835-
Py_SETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks));
1835+
Py_XSETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks));
18361836
if (line == NULL)
18371837
goto error;
18381838
Py_DECREF(chunks);

Modules/_json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ scanner_init(PyObject *self, PyObject *args, PyObject *kwds)
17171717
}
17181718
else if (PyUnicode_Check(s->encoding)) {
17191719
PyObject *tmp = PyUnicode_AsEncodedString(s->encoding, NULL, NULL);
1720-
Py_SETREF(s->encoding, tmp);
1720+
Py_XSETREF(s->encoding, tmp);
17211721
}
17221722
if (s->encoding == NULL)
17231723
goto bail;

0 commit comments

Comments
 (0)