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

Skip to content

Commit 9e897f4

Browse files
committed
Mark Favas reported that gcc caught me using casts as lvalues. Dodge it.
1 parent af92218 commit 9e897f4

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Objects/stringobject.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static PyStringObject *nullstring;
3636
PyObject *
3737
PyString_FromStringAndSize(const char *str, int size)
3838
{
39-
PyStringObject *op;
39+
register PyStringObject *op;
4040
#ifndef DONT_SHARE_SHORT_STRINGS
4141
if (size == 0 && (op = nullstring) != NULL) {
4242
#ifdef COUNT_ALLOCS
@@ -73,11 +73,13 @@ PyString_FromStringAndSize(const char *str, int size)
7373
op->ob_sval[size] = '\0';
7474
#ifndef DONT_SHARE_SHORT_STRINGS
7575
if (size == 0) {
76-
PyString_InternInPlace(&(PyObject *)op);
76+
PyObject *t = (PyObject *)op;
77+
PyString_InternInPlace(&t);
7778
nullstring = op;
7879
Py_INCREF(op);
7980
} else if (size == 1 && str != NULL) {
80-
PyString_InternInPlace(&(PyObject *)op);
81+
PyObject *t = (PyObject *)op;
82+
PyString_InternInPlace(&t);
8183
characters[*str & UCHAR_MAX] = op;
8284
Py_INCREF(op);
8385
}
@@ -89,7 +91,7 @@ PyObject *
8991
PyString_FromString(const char *str)
9092
{
9193
register size_t size = strlen(str);
92-
PyStringObject *op;
94+
register PyStringObject *op;
9395
if (size > INT_MAX) {
9496
PyErr_SetString(PyExc_OverflowError,
9597
"string is too long for a Python string");
@@ -127,11 +129,13 @@ PyString_FromString(const char *str)
127129
strcpy(op->ob_sval, str);
128130
#ifndef DONT_SHARE_SHORT_STRINGS
129131
if (size == 0) {
130-
PyString_InternInPlace(&(PyObject *)op);
132+
PyObject *t = (PyObject *)op;
133+
PyString_InternInPlace(&t);
131134
nullstring = op;
132135
Py_INCREF(op);
133136
} else if (size == 1) {
134-
PyString_InternInPlace(&(PyObject *)op);
137+
PyObject *t = (PyObject *)op;
138+
PyString_InternInPlace(&t);
135139
characters[*str & UCHAR_MAX] = op;
136140
Py_INCREF(op);
137141
}

0 commit comments

Comments
 (0)