Issue 13744: raw byte strings are described in a confusing way (original) (raw)

Created on 2012-01-09 13:34 by barry, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stringByteLiteralBR.docx j.chadwick,2012-03-29 13:52 Correct update to documentation
Messages (10)
msg150936 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2012-01-09 13:34
The lexical analysis documentation says this: http://docs.python.org/py3k/reference/lexical_analysis.html?highlight=raw%20bytes "Bytes literals are always prefixed with 'b' or 'B';..." "Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R';..." But that would lead you to believe that to get raw byte strings you should use rb"foo". In fact, that's a SyntaxError in Python 2.6+ and Python 3. What *does* work though is br"foo". Either Python should accept both spellings (harder) or the documentation should make it clear that the 'b' must preceded the 'r'.
msg150940 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-09 15:15
> Either Python should accept both spellings +1. Been annoyed several times by this.
msg150941 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2012-01-09 15:18
On Jan 09, 2012, at 03:15 PM, Antoine Pitrou wrote: > >Antoine Pitrou <pitrou@free.fr> added the comment: > >> Either Python should accept both spellings > >+1. Been annoyed several times by this. The $64k question: is this a new feature or a bug? :)
msg150942 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-09 15:35
> The $64k question: is this a new feature or a bug? :) Most certainly a feature...
msg150944 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2012-01-09 15:44
On Jan 09, 2012, at 03:35 PM, Antoine Pitrou wrote: > >Antoine Pitrou <pitrou@free.fr> added the comment: > >> The $64k question: is this a new feature or a bug? :) > >Most certainly a feature... In that case, since we can only add the new prefixes to 3.3, I still think we need to fix the documentation to remove the confusion for stable releases.
msg157046 - (view) Author: Joseph Chadwick (j.chadwick) Date: 2012-03-29 13:43
The attached replaces the text for the documentation in 2.4.1 between the lexical definitions table and the escape sequence table. The only change is the following addition to the paragraph on string and byte literals prefixed by 'r' or 'R': When a byte literal is prefixed with both 'r' or 'R' and 'b' or 'B', the b must precede the r, as in: 'Br', 'bR', or 'BR' and not 'Rb', 'rB', or 'RB'.
msg157047 - (view) Author: Joseph Chadwick (j.chadwick) Date: 2012-03-29 13:52
I uploaded before making the final save, so the first document is incomplete. (that's embarrassing)
msg157122 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-30 02:52
Thanks for the contribution. Could you post your suggested wording as a plain text file?
msg157123 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-30 02:53
Actually it’s fine, we already have the text in your message :)
msg199667 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 08:01
3.3 is now released with both "br" and "rb" allowed, and in 2.7 the current text looks good enough for me.
History
Date User Action Args
2022-04-11 14:57:25 admin set github: 57953
2013-10-13 08:01:56 georg.brandl set status: open -> closednosy: + georg.brandlmessages: + resolution: out of date
2012-03-30 02:53:17 eric.araujo set messages: +
2012-03-30 02:52:30 eric.araujo set nosy: + eric.araujomessages: +
2012-03-29 14:19:53 loewis set files: - stringByteLiteralBR.docx
2012-03-29 13:52:28 j.chadwick set files: + stringByteLiteralBR.docxmessages: +
2012-03-29 13:43:12 j.chadwick set files: + stringByteLiteralBR.docxnosy: + j.chadwickmessages: + type: enhancement
2012-01-14 05:13:01 terry.reedy set nosy: + terry.reedyversions: - Python 3.1
2012-01-09 15:44:35 barry set messages: +
2012-01-09 15:35:50 pitrou set messages: +
2012-01-09 15🔞46 barry set messages: +
2012-01-09 15:15:20 pitrou set nosy: + gvanrossum, pitroumessages: +
2012-01-09 13:34:21 barry create