This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Replace string with bytes in doc of unicode-escape an raw-unicode-escape
Type: Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: abarry, docs@python, mdk, python-dev, serhiy.storchaka, xiang.zhang
Priority: normal Keywords: patch

Created on 2016-11-20 13:58 by xiang.zhang, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unicode-escape-doc.patch xiang.zhang, 2016-11-20 13:58 review
unicode-escape-doc_v2.patch xiang.zhang, 2016-11-20 14:21 small wording nit improvement suggested by ebarry review
unicode-escape-doc_v3.patch xiang.zhang, 2016-11-20 15:03 review
Messages (8)
msg281263 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-11-20 13:58
The docs of the encoders of unicode-escape and raw-unicode-escape still tell the result of the encoding is Python string object. It should be Python bytes object.
msg281269 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2016-11-20 14:43
The inconcistencies were introduced in hg changeset 41703:7993f23ad46c, git commit:

commit 40ec96630b96f077c8b5746ab0ec038f95aede8b
Author: Walter Dörwald <walter@livinglogic.de>
Date:   Sat May 12 11:08:06 2007 +0000

    Change PyUnicode_EncodeUnicodeEscape() to return a bytes object.
    However PyUnicode_AsUnicodeEscapeString() (which is used by
    Objects/fileobject.c::file_repr()) still returns a str8 object.
    Give unicode_repr() it's own implementation which returns a str8
    object (it was formerly just calling unicodeescape_string()
    which was used to implement PyUnicode_EncodeUnicodeEscape() too),
    because once repr() is required to return unicode objects it
    needs its own implementation anyway.

(PyUnicode_EncodeUnicodeEscape was the old name for PyUnicode_AsUnicodeEscapeString (since 06ade3ac0d12beacd84382bd5fc8baf1c21c0e74).)

I searched in the documentation for "python string" and it looks like  PyUnicode_EncodeCharmap is documented to return a string, but it returns bytes (same issue), therefore, the same issue happen for PyUnicode_AsCharmapString which uses PyUnicode_EncodeCharmap.
msg281270 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-20 14:45
Good catch Xiang!

But I think the word "Python" in "Python bytes object" is redundant. It was needed in "Python string object" to distinguish from "C string" and "Python Unicode object".
msg281271 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-20 14:46
For PyUnicode_AsCharmapString and PyUnicode_EncodeCharmap see issue28749.
msg281272 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-11-20 15:03
> But I think the word "Python" in "Python bytes object" is redundant. It was needed in "Python string object" to distinguish from "C string" and "Python Unicode object".

Make sense. This "Python" actually appears in many places in the docs. I only change the related parts of this issue.
msg281273 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2016-11-20 15:05
So, lgtm.
msg281275 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-20 15:14
LGTM.
msg281276 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-11-20 15:22
New changeset 059b8e15b738 by Serhiy Storchaka in branch '3.5':
Issue #28750: Fixed docs of of unicode-escape an raw-unicode-escape C API.
https://hg.python.org/cpython/rev/059b8e15b738

New changeset 0c6fccf04a79 by Serhiy Storchaka in branch '3.6':
Issue #28750: Fixed docs of of unicode-escape an raw-unicode-escape C API.
https://hg.python.org/cpython/rev/0c6fccf04a79

New changeset deff7bf26d00 by Serhiy Storchaka in branch 'default':
Issue #28750: Fixed docs of of unicode-escape an raw-unicode-escape C API.
https://hg.python.org/cpython/rev/deff7bf26d00
History
Date User Action Args
2022-04-11 14:58:39adminsetgithub: 72936
2016-11-20 15:22:29serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-11-20 15:22:02python-devsetnosy: + python-dev
messages: + msg281276
2016-11-20 15:14:26serhiy.storchakasetassignee: docs@python -> serhiy.storchaka
messages: + msg281275
2016-11-20 15:05:44mdksetmessages: + msg281273
2016-11-20 15:03:24xiang.zhangsetfiles: + unicode-escape-doc_v3.patch

messages: + msg281272
2016-11-20 14:46:30serhiy.storchakasetmessages: + msg281271
2016-11-20 14:45:25serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg281270
2016-11-20 14:43:14mdksetnosy: + mdk
messages: + msg281269
2016-11-20 14:23:13abarrysetstage: patch review -> commit review
2016-11-20 14:21:35xiang.zhangsetfiles: + unicode-escape-doc_v2.patch
2016-11-20 14:03:20abarrysetnosy: + abarry
2016-11-20 13:58:32xiang.zhangcreate