Skip to content

Commit 519a042

Browse files
author
Thomas Heller
committed
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
#define for PyObject_Unicode in object.h.
1 parent 6e8ea0f commit 519a042

13 files changed

Lines changed: 25 additions & 26 deletions

File tree

Include/object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ PyAPI_FUNC(void) _Py_BreakPoint(void);
432432
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
433433
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
434434
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
435-
#define PyObject_Unicode PyObject_Str /* Compatibility */
436435
PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
437436
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
438437
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);

Modules/_csv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
11851185
else {
11861186
PyObject *str;
11871187

1188-
str = PyObject_Unicode(field);
1188+
str = PyObject_Str(field);
11891189
Py_DECREF(field);
11901190
if (str == NULL)
11911191
return NULL;

Modules/_ctypes/callproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...)
785785
goto error;
786786
} else
787787
PyErr_Clear();
788-
msg_str = PyObject_Unicode(v);
788+
msg_str = PyObject_Str(v);
789789
if (msg_str)
790790
PyUnicode_AppendAndDel(&s, msg_str);
791791
else {

Modules/_testcapimodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,12 @@ test_long_numbits(PyObject *self)
615615
return Py_None;
616616
}
617617

618-
/* Example passing NULLs to PyObject_Str(NULL) and PyObject_Unicode(NULL). */
618+
/* Example passing NULLs to PyObject_Str(NULL). */
619619

620620
static PyObject *
621621
test_null_strings(PyObject *self)
622622
{
623-
PyObject *o1 = PyObject_Str(NULL), *o2 = PyObject_Unicode(NULL);
623+
PyObject *o1 = PyObject_Str(NULL), *o2 = PyObject_Str(NULL);
624624
PyObject *tuple = PyTuple_Pack(2, o1, o2);
625625
Py_XDECREF(o1);
626626
Py_XDECREF(o2);

Modules/cjkcodecs/multibytecodec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ MultibyteCodec_Encode(MultibyteCodecObject *self,
552552
if (PyUnicode_Check(arg))
553553
ucvt = NULL;
554554
else {
555-
arg = ucvt = PyObject_Unicode(arg);
555+
arg = ucvt = PyObject_Str(arg);
556556
if (arg == NULL)
557557
return NULL;
558558
else if (!PyUnicode_Check(arg)) {
@@ -728,7 +728,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
728728
if (PyUnicode_Check(unistr))
729729
ucvt = NULL;
730730
else {
731-
unistr = ucvt = PyObject_Unicode(unistr);
731+
unistr = ucvt = PyObject_Str(unistr);
732732
if (unistr == NULL)
733733
return NULL;
734734
else if (!PyUnicode_Check(unistr)) {

Modules/datetimemodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ date_format(PyDateTime_Date *self, PyObject *args)
24442444

24452445
/* if the format is zero length, return str(self) */
24462446
if (PyUnicode_GetSize(format) == 0)
2447-
return PyObject_Unicode((PyObject *)self);
2447+
return PyObject_Str((PyObject *)self);
24482448

24492449
return PyObject_CallMethod((PyObject *)self, "strftime", "O", format);
24502450
}
@@ -3220,7 +3220,7 @@ time_format(PyDateTime_Time *self, PyObject *args)
32203220

32213221
/* if the format is zero length, return str(self) */
32223222
if (PyUnicode_GetSize(format) == 0)
3223-
return PyObject_Unicode((PyObject *)self);
3223+
return PyObject_Str((PyObject *)self);
32243224

32253225
return PyObject_CallMethod((PyObject *)self, "strftime", "O", format);
32263226
}

Modules/grpmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ grp_getgrnam(PyObject *self, PyObject *pyo_name)
110110
char *name;
111111
struct group *p;
112112

113-
py_str_name = PyObject_Unicode(pyo_name);
113+
py_str_name = PyObject_Str(pyo_name);
114114
if (!py_str_name)
115115
return NULL;
116116
name = PyUnicode_AsString(py_str_name);

Objects/exceptions.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ BaseException_str(PyBaseExceptionObject *self)
8989
case 0:
9090
return PyUnicode_FromString("");
9191
case 1:
92-
return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0));
92+
return PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
9393
default:
94-
return PyObject_Unicode(self->args);
94+
return PyObject_Str(self->args);
9595
}
9696
}
9797

@@ -939,7 +939,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
939939
have_lineno = (self->lineno != NULL) && PyInt_CheckExact(self->lineno);
940940

941941
if (!filename && !have_lineno)
942-
return PyObject_Unicode(self->msg ? self->msg : Py_None);
942+
return PyObject_Str(self->msg ? self->msg : Py_None);
943943

944944
if (filename && have_lineno)
945945
return PyUnicode_FromFormat("%S (%s, line %ld)",

Objects/stringlib/string_format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ do_conversion(PyObject *obj, STRINGLIB_CHAR conversion)
770770
case 'r':
771771
return PyObject_Repr(obj);
772772
case 's':
773-
return PyObject_Unicode(obj);
773+
return PyObject_Str(obj);
774774
default:
775775
PyErr_Format(PyExc_ValueError,
776776
"Unknown converion specifier %c",

Objects/stringlib/unicodedefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define STRINGLIB_NEW PyUnicode_FromUnicode
2121
#define STRINGLIB_RESIZE PyUnicode_Resize
2222
#define STRINGLIB_CHECK PyUnicode_Check
23-
#define STRINGLIB_TOSTR PyObject_Unicode
23+
#define STRINGLIB_TOSTR PyObject_Str
2424

2525
#define STRINGLIB_WANT_CONTAINS_OBJ 1
2626

0 commit comments

Comments
 (0)