Skip to content

Commit cda8094

Browse files
committed
Issue python#15984: Merge PyUnicode doc from 3.5
2 parents 8ca020e + 20d3255 commit cda8094

35 files changed

+64
-70
lines changed

Doc/c-api/exceptions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ an error value).
285285
.. c:function:: int PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level)
286286
287287
Issue a warning message. The *category* argument is a warning category (see
288-
below) or *NULL*; the *message* argument is an UTF-8 encoded string. *stack_level* is a
288+
below) or *NULL*; the *message* argument is a UTF-8 encoded string. *stack_level* is a
289289
positive number giving a number of stack frames; the warning will be issued from
290290
the currently executing line of code in that stack frame. A *stack_level* of 1
291291
is the function calling :c:func:`PyErr_WarnEx`, 2 is the function above that,
@@ -617,7 +617,7 @@ The following functions are used to create and modify Unicode exceptions from C.
617617
.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
618618
619619
Create a :class:`UnicodeTranslateError` object with the attributes *object*,
620-
*length*, *start*, *end* and *reason*. *reason* is an UTF-8 encoded string.
620+
*length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string.
621621
622622
.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
623623
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)

Doc/c-api/import.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Importing Modules
7272
7373
.. c:function:: PyObject* PyImport_ImportModuleLevel(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
7474
75-
Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is an
75+
Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is a
7676
UTF-8 encoded string instead of a Unicode object.
7777
7878
.. versionchanged:: 3.3

Doc/c-api/method.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Method Objects
4949
.. index:: object: method
5050
5151
Methods are bound function objects. Methods are always bound to an instance of
52-
an user-defined class. Unbound methods (methods bound to a class object) are
52+
a user-defined class. Unbound methods (methods bound to a class object) are
5353
no longer available.
5454
5555

Doc/c-api/module.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Module Objects
5050
5151
.. c:function:: PyObject* PyModule_New(const char *name)
5252
53-
Similar to :c:func:`PyImport_NewObject`, but the name is an UTF-8 encoded
53+
Similar to :c:func:`PyImport_NewObject`, but the name is a UTF-8 encoded
5454
string instead of a Unicode object.
5555
5656

Doc/c-api/unicode.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ APIs:
423423
424424
.. c:function:: PyObject *PyUnicode_FromString(const char *u)
425425
426-
Create a Unicode object from an UTF-8 encoded null-terminated char buffer
426+
Create a Unicode object from a UTF-8 encoded null-terminated char buffer
427427
*u*.
428428
429429
@@ -556,14 +556,13 @@ APIs:
556556
.. c:function:: PyObject* PyUnicode_FromEncodedObject(PyObject *obj, \
557557
const char *encoding, const char *errors)
558558
559-
Coerce an encoded object *obj* to an Unicode object and return a reference with
560-
incremented refcount.
559+
Decode an encoded object *obj* to a Unicode object.
561560
562561
:class:`bytes`, :class:`bytearray` and other
563562
:term:`bytes-like objects <bytes-like object>`
564563
are decoded according to the given *encoding* and using the error handling
565564
defined by *errors*. Both can be *NULL* to have the interface use the default
566-
values (see the next section for details).
565+
values (see :ref:`builtincodecs` for details).
567566
568567
All other objects, including Unicode objects, cause a :exc:`TypeError` to be
569568
set.
@@ -745,8 +744,11 @@ Extension modules can continue using them, as they will not be removed in Python
745744
746745
.. c:function:: PyObject* PyUnicode_FromObject(PyObject *obj)
747746
748-
Shortcut for ``PyUnicode_FromEncodedObject(obj, NULL, "strict")`` which is used
749-
throughout the interpreter whenever coercion to Unicode is needed.
747+
Copy an instance of a Unicode subtype to a new true Unicode object if
748+
necessary. If *obj* is already a true Unicode object (not a subtype),
749+
return the reference with incremented refcount.
750+
751+
Objects other than Unicode or its subtypes will cause a :exc:`TypeError`.
750752
751753
752754
Locale Encoding
@@ -1224,7 +1226,7 @@ These are the UTF-16 codec APIs:
12241226
12251227
If *Py_UNICODE_WIDE* is defined, a single :c:type:`Py_UNICODE` value may get
12261228
represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE`
1227-
values is interpreted as an UCS-2 character.
1229+
values is interpreted as a UCS-2 character.
12281230
12291231
Return *NULL* if an exception was raised by the codec.
12301232

Doc/howto/urllib2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ you can do so via the :func:`~urllib.request.urlretrieve` function::
6464
html = open(local_filename)
6565

6666
Many uses of urllib will be that simple (note that instead of an 'http:' URL we
67-
could have used an URL starting with 'ftp:', 'file:', etc.). However, it's the
67+
could have used a URL starting with 'ftp:', 'file:', etc.). However, it's the
6868
purpose of this tutorial to explain the more complicated cases, concentrating on
6969
HTTP.
7070

Doc/library/heapq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ for a tournament. The numbers below are *k*, not ``a[k]``::
242242

243243
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
244244

245-
In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In an usual
245+
In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a usual
246246
binary tournament we see in sports, each cell is the winner over the two cells
247247
it tops, and we can trace the winner down the tree to see all opponents s/he
248248
had. However, in many computer applications of such tournaments, we do not need

Doc/library/logging.handlers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ supports sending logging messages to a Web server, using either ``GET`` or
874874

875875
.. method:: emit(record)
876876

877-
Sends the record to the Web server as an URL-encoded dictionary. The
877+
Sends the record to the Web server as a URL-encoded dictionary. The
878878
:meth:`mapLogRecord` method is used to convert the record to the
879879
dictionary to be sent.
880880

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ features:
17621762
``os.path.join(os.path.dirname(path), result)``.
17631763

17641764
If the *path* is a string object, the result will also be a string object,
1765-
and the call may raise an UnicodeDecodeError. If the *path* is a bytes
1765+
and the call may raise a UnicodeDecodeError. If the *path* is a bytes
17661766
object, the result will be a bytes object.
17671767

17681768
This function can also support :ref:`paths relative to directory descriptors

Doc/library/re.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ those found in Perl.
1212

1313
Both patterns and strings to be searched can be Unicode strings as well as
1414
8-bit strings. However, Unicode strings and 8-bit strings cannot be mixed:
15-
that is, you cannot match an Unicode string with a byte pattern or
15+
that is, you cannot match a Unicode string with a byte pattern or
1616
vice-versa; similarly, when asking for a substitution, the replacement
1717
string must be of the same type as both the pattern and the search string.
1818

0 commit comments

Comments
 (0)