Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2a404b63
Commit
2a404b63
authored
Jan 22, 2017
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28769: The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()
is now of type "const char *" rather of "char *".
parent
d5287910
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
26 additions
and
13 deletions
+26
-13
Doc/c-api/unicode.rst
Doc/c-api/unicode.rst
+8
-2
Doc/whatsnew/3.7.rst
Doc/whatsnew/3.7.rst
+4
-0
Include/unicodeobject.h
Include/unicodeobject.h
+2
-2
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_dbmmodule.c
Modules/_dbmmodule.c
+1
-1
Modules/_decimal/_decimal.c
Modules/_decimal/_decimal.c
+1
-1
Modules/_gdbmmodule.c
Modules/_gdbmmodule.c
+1
-1
Objects/object.c
Objects/object.c
+4
-4
Objects/unicodeobject.c
Objects/unicodeobject.c
+2
-2
No files found.
Doc/c-api/unicode.rst
View file @
2a404b63
...
...
@@ -1038,7 +1038,7 @@ These are the UTF-8 codec APIs:
raised by the codec.
.. c:function:: char* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
.. c:function:: c
onst c
har* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
Return a pointer to the UTF-8 encoding of the Unicode object, and
store the size of the encoded representation (in bytes) in *size*. The
...
...
@@ -1055,13 +1055,19 @@ These are the UTF-8 codec APIs:
.. versionadded:: 3.3
.. versionchanged:: 3.7
The return type is now ``const char *`` rather of ``char *``.
.. c:function:: char* PyUnicode_AsUTF8(PyObject *unicode)
.. c:function:: c
onst c
har* PyUnicode_AsUTF8(PyObject *unicode)
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
.. versionadded:: 3.3
.. versionchanged:: 3.7
The return type is now ``const char *`` rather of ``char *``.
.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
...
...
Doc/whatsnew/3.7.rst
View file @
2a404b63
...
...
@@ -124,6 +124,10 @@ Build and C API Changes
and :c:type:`wrapperbase` are now of type ``const char *`` rather of
``char *``. (Contributed by Serhiy Storchaka in :issue:`28761`.)
* The result of :c:func:`PyUnicode_AsUTF8AndSize` and :c:func:`PyUnicode_AsUTF8`
is now of type ``const char *`` rather of ``char *``.
(Contributed by Serhiy Storchaka in :issue:`28769`.)
Deprecated
==========
...
...
Include/unicodeobject.h
View file @
2a404b63
...
...
@@ -1135,7 +1135,7 @@ PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
*/
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
char
*
)
PyUnicode_AsUTF8AndSize
(
PyAPI_FUNC
(
c
onst
c
har
*
)
PyUnicode_AsUTF8AndSize
(
PyObject
*
unicode
,
Py_ssize_t
*
size
);
#define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize
...
...
@@ -1162,7 +1162,7 @@ PyAPI_FUNC(char *) PyUnicode_AsUTF8AndSize(
*/
#ifndef Py_LIMITED_API
PyAPI_FUNC
(
char
*
)
PyUnicode_AsUTF8
(
PyObject
*
unicode
);
PyAPI_FUNC
(
c
onst
c
har
*
)
PyUnicode_AsUTF8
(
PyObject
*
unicode
);
#define _PyUnicode_AsString PyUnicode_AsUTF8
#endif
...
...
Misc/NEWS
View file @
2a404b63
...
...
@@ -614,6 +614,9 @@ Windows
C API
-----
- Issue #28769: The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()
is now of type "const char *" rather of "char *".
- Issue #29058: All stable API extensions added after Python 3.2 are now
available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of
the minimum Python version supporting this API.
...
...
Modules/_dbmmodule.c
View file @
2a404b63
...
...
@@ -239,7 +239,7 @@ dbm_contains(PyObject *self, PyObject *arg)
return
-
1
;
}
if
(
PyUnicode_Check
(
arg
))
{
key
.
dptr
=
PyUnicode_AsUTF8AndSize
(
arg
,
&
size
);
key
.
dptr
=
(
char
*
)
PyUnicode_AsUTF8AndSize
(
arg
,
&
size
);
key
.
dsize
=
size
;
if
(
key
.
dptr
==
NULL
)
return
-
1
;
...
...
Modules/_decimal/_decimal.c
View file @
2a404b63
...
...
@@ -3199,7 +3199,7 @@ dec_format(PyObject *dec, PyObject *args)
}
if
(
PyUnicode_Check
(
fmtarg
))
{
fmt
=
PyUnicode_AsUTF8AndSize
(
fmtarg
,
&
size
);
fmt
=
(
char
*
)
PyUnicode_AsUTF8AndSize
(
fmtarg
,
&
size
);
if
(
fmt
==
NULL
)
{
return
NULL
;
}
...
...
Modules/_gdbmmodule.c
View file @
2a404b63
...
...
@@ -319,7 +319,7 @@ dbm_contains(PyObject *self, PyObject *arg)
return
-
1
;
}
if
(
PyUnicode_Check
(
arg
))
{
key
.
dptr
=
PyUnicode_AsUTF8AndSize
(
arg
,
&
size
);
key
.
dptr
=
(
char
*
)
PyUnicode_AsUTF8AndSize
(
arg
,
&
size
);
key
.
dsize
=
size
;
if
(
key
.
dptr
==
NULL
)
return
-
1
;
...
...
Objects/object.c
View file @
2a404b63
...
...
@@ -890,10 +890,10 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
if
(
tp
->
tp_getattro
!=
NULL
)
return
(
*
tp
->
tp_getattro
)(
v
,
name
);
if
(
tp
->
tp_getattr
!=
NULL
)
{
char
*
name_str
=
PyUnicode_AsUTF8
(
name
);
c
onst
c
har
*
name_str
=
PyUnicode_AsUTF8
(
name
);
if
(
name_str
==
NULL
)
return
NULL
;
return
(
*
tp
->
tp_getattr
)(
v
,
name_str
);
return
(
*
tp
->
tp_getattr
)(
v
,
(
char
*
)
name_str
);
}
PyErr_Format
(
PyExc_AttributeError
,
"'%.50s' object has no attribute '%U'"
,
...
...
@@ -934,10 +934,10 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
return
err
;
}
if
(
tp
->
tp_setattr
!=
NULL
)
{
char
*
name_str
=
PyUnicode_AsUTF8
(
name
);
c
onst
c
har
*
name_str
=
PyUnicode_AsUTF8
(
name
);
if
(
name_str
==
NULL
)
return
-
1
;
err
=
(
*
tp
->
tp_setattr
)(
v
,
name_str
,
value
);
err
=
(
*
tp
->
tp_setattr
)(
v
,
(
char
*
)
name_str
,
value
);
Py_DECREF
(
name
);
return
err
;
}
...
...
Objects/unicodeobject.c
View file @
2a404b63
...
...
@@ -3972,7 +3972,7 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
}
c
har
*
c
onst
char
*
PyUnicode_AsUTF8AndSize
(
PyObject
*
unicode
,
Py_ssize_t
*
psize
)
{
PyObject
*
bytes
;
...
...
@@ -4007,7 +4007,7 @@ PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
return
PyUnicode_UTF8
(
unicode
);
}
c
har
*
c
onst
char
*
PyUnicode_AsUTF8
(
PyObject
*
unicode
)
{
return
PyUnicode_AsUTF8AndSize
(
unicode
,
NULL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment