+26
-13
lines changedFilter options
+26
-13
lines changed Original file line number Diff line number Diff line change
@@ -1038,7 +1038,7 @@ These are the UTF-8 codec APIs:
1038
1038
raised by the codec.
1039
1039
1040
1040
1041
-
.. c:function:: char* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
1041
+
.. c:function:: const char* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
1042
1042
1043
1043
Return a pointer to the UTF-8 encoding of the Unicode object, and
1044
1044
store the size of the encoded representation (in bytes) in *size*. The
@@ -1055,13 +1055,19 @@ These are the UTF-8 codec APIs:
1055
1055
1056
1056
.. versionadded:: 3.3
1057
1057
1058
+
.. versionchanged:: 3.7
1059
+
The return type is now ``const char *`` rather of ``char *``.
1060
+
1058
1061
1059
-
.. c:function:: char* PyUnicode_AsUTF8(PyObject *unicode)
1062
+
.. c:function:: const char* PyUnicode_AsUTF8(PyObject *unicode)
1060
1063
1061
1064
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
1062
1065
1063
1066
.. versionadded:: 3.3
1064
1067
1068
+
.. versionchanged:: 3.7
1069
+
The return type is now ``const char *`` rather of ``char *``.
1070
+
1065
1071
1066
1072
.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
1067
1073
Original file line number Diff line number Diff line change
@@ -124,6 +124,10 @@ Build and C API Changes
124
124
and :c:type:`wrapperbase` are now of type ``const char *`` rather of
125
125
``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.)
126
126
127
+
* The result of :c:func:`PyUnicode_AsUTF8AndSize` and :c:func:`PyUnicode_AsUTF8`
128
+
is now of type ``const char *`` rather of ``char *``.
129
+
(Contributed by Serhiy Storchaka in :issue:`28769`.)
130
+
127
131
128
132
Deprecated
129
133
==========
Original file line number Diff line number Diff line change
@@ -1135,7 +1135,7 @@ PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
1135
1135
*/
1136
1136
1137
1137
#ifndef Py_LIMITED_API
1138
-
PyAPI_FUNC(char *) PyUnicode_AsUTF8AndSize(
1138
+
PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize(
1139
1139
PyObject *unicode,
1140
1140
Py_ssize_t *size);
1141
1141
#define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize
@@ -1162,7 +1162,7 @@ PyAPI_FUNC(char *) PyUnicode_AsUTF8AndSize(
1162
1162
*/
1163
1163
1164
1164
#ifndef Py_LIMITED_API
1165
-
PyAPI_FUNC(char *) PyUnicode_AsUTF8(PyObject *unicode);
1165
+
PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
1166
1166
#define _PyUnicode_AsString PyUnicode_AsUTF8
1167
1167
#endif
1168
1168
Original file line number Diff line number Diff line change
@@ -614,6 +614,9 @@ Windows
614
614
C API
615
615
-----
616
616
617
+
- Issue #28769: The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()
618
+
is now of type "const char *" rather of "char *".
619
+
617
620
- Issue #29058: All stable API extensions added after Python 3.2 are now
618
621
available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of
619
622
the minimum Python version supporting this API.
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ dbm_contains(PyObject *self, PyObject *arg)
239
239
return -1;
240
240
}
241
241
if (PyUnicode_Check(arg)) {
242
-
key.dptr = PyUnicode_AsUTF8AndSize(arg, &size);
242
+
key.dptr = (char *)PyUnicode_AsUTF8AndSize(arg, &size);
243
243
key.dsize = size;
244
244
if (key.dptr == NULL)
245
245
return -1;
Original file line number Diff line number Diff line change
@@ -3199,7 +3199,7 @@ dec_format(PyObject *dec, PyObject *args)
3199
3199
}
3200
3200
3201
3201
if (PyUnicode_Check(fmtarg)) {
3202
-
fmt = PyUnicode_AsUTF8AndSize(fmtarg, &size);
3202
+
fmt = (char *)PyUnicode_AsUTF8AndSize(fmtarg, &size);
3203
3203
if (fmt == NULL) {
3204
3204
return NULL;
3205
3205
}
Original file line number Diff line number Diff line change
@@ -319,7 +319,7 @@ dbm_contains(PyObject *self, PyObject *arg)
319
319
return -1;
320
320
}
321
321
if (PyUnicode_Check(arg)) {
322
-
key.dptr = PyUnicode_AsUTF8AndSize(arg, &size);
322
+
key.dptr = (char *)PyUnicode_AsUTF8AndSize(arg, &size);
323
323
key.dsize = size;
324
324
if (key.dptr == NULL)
325
325
return -1;
Original file line number Diff line number Diff line change
@@ -890,10 +890,10 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
890
890
if (tp->tp_getattro != NULL)
891
891
return (*tp->tp_getattro)(v, name);
892
892
if (tp->tp_getattr != NULL) {
893
-
char *name_str = PyUnicode_AsUTF8(name);
893
+
const char *name_str = PyUnicode_AsUTF8(name);
894
894
if (name_str == NULL)
895
895
return NULL;
896
-
return (*tp->tp_getattr)(v, name_str);
896
+
return (*tp->tp_getattr)(v, (char *)name_str);
897
897
}
898
898
PyErr_Format(PyExc_AttributeError,
899
899
"'%.50s' object has no attribute '%U'",
@@ -934,10 +934,10 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
934
934
return err;
935
935
}
936
936
if (tp->tp_setattr != NULL) {
937
-
char *name_str = PyUnicode_AsUTF8(name);
937
+
const char *name_str = PyUnicode_AsUTF8(name);
938
938
if (name_str == NULL)
939
939
return -1;
940
-
err = (*tp->tp_setattr)(v, name_str, value);
940
+
err = (*tp->tp_setattr)(v, (char *)name_str, value);
941
941
Py_DECREF(name);
942
942
return err;
943
943
}
Original file line number Diff line number Diff line change
@@ -3972,7 +3972,7 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
3972
3972
}
3973
3973
3974
3974
3975
-
char*
3975
+
const char *
3976
3976
PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
3977
3977
{
3978
3978
PyObject *bytes;
@@ -4007,7 +4007,7 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
4007
4007
return PyUnicode_UTF8(unicode);
4008
4008
}
4009
4009
4010
-
char*
4010
+
const char *
4011
4011
PyUnicode_AsUTF8(PyObject *unicode)
4012
4012
{
4013
4013
return PyUnicode_AsUTF8AndSize(unicode, NULL);
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4