Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw byte strings are described in a confusing way #57953

Closed
warsaw opened this issue Jan 9, 2012 · 10 comments
Closed

raw byte strings are described in a confusing way #57953

warsaw opened this issue Jan 9, 2012 · 10 comments
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@warsaw
Copy link
Member

warsaw commented Jan 9, 2012

BPO 13744
Nosy @gvanrossum, @warsaw, @birkenfeld, @terryjreedy, @pitrou, @merwok
Files
  • stringByteLiteralBR.docx: Correct update to documentation
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-10-13.08:01:56.872>
    created_at = <Date 2012-01-09.13:34:21.499>
    labels = ['type-feature', 'docs']
    title = 'raw byte strings are described in a confusing way'
    updated_at = <Date 2013-10-13.08:01:56.870>
    user = 'https://github.com/warsaw'

    bugs.python.org fields:

    activity = <Date 2013-10-13.08:01:56.870>
    actor = 'georg.brandl'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2013-10-13.08:01:56.872>
    closer = 'georg.brandl'
    components = ['Documentation']
    creation = <Date 2012-01-09.13:34:21.499>
    creator = 'barry'
    dependencies = []
    files = ['25065']
    hgrepos = []
    issue_num = 13744
    keywords = []
    message_count = 10.0
    messages = ['150936', '150940', '150941', '150942', '150944', '157046', '157047', '157122', '157123', '199667']
    nosy_count = 8.0
    nosy_names = ['gvanrossum', 'barry', 'georg.brandl', 'terry.reedy', 'pitrou', 'eric.araujo', 'docs@python', 'j.chadwick']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13744'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    @warsaw
    Copy link
    Member Author

    warsaw commented Jan 9, 2012

    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'.

    @warsaw warsaw added the docs Documentation in the Doc dir label Jan 9, 2012
    @pitrou
    Copy link
    Member

    pitrou commented Jan 9, 2012

    Either Python should accept both spellings

    +1. Been annoyed several times by this.

    @warsaw
    Copy link
    Member Author

    warsaw commented Jan 9, 2012

    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? :)

    @pitrou
    Copy link
    Member

    pitrou commented Jan 9, 2012

    The $64k question: is this a new feature or a bug? :)

    Most certainly a feature...

    @warsaw
    Copy link
    Member Author

    warsaw commented Jan 9, 2012

    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.

    @jchadwick
    Copy link
    Mannequin

    jchadwick mannequin commented Mar 29, 2012

    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'.

    @jchadwick jchadwick mannequin added the type-feature A feature request or enhancement label Mar 29, 2012
    @jchadwick
    Copy link
    Mannequin

    jchadwick mannequin commented Mar 29, 2012

    I uploaded before making the final save, so the first document is incomplete.

    (that's embarrassing)

    @merwok
    Copy link
    Member

    merwok commented Mar 30, 2012

    Thanks for the contribution. Could you post your suggested wording as a plain text file?

    @merwok
    Copy link
    Member

    merwok commented Mar 30, 2012

    Actually it’s fine, we already have the text in your message :)

    @birkenfeld
    Copy link
    Member

    3.3 is now released with both "br" and "rb" allowed, and in 2.7 the current text looks good enough for me.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants