GithubHelp home page GithubHelp logo

chokes on `rb"literal"` about yapf HOT 8 CLOSED

google avatar google commented on July 24, 2024 1
chokes on `rb"literal"`

from yapf.

Comments (8)

bwendling avatar bwendling commented on July 24, 2024

The problem is that the original code isn't correct. "rb" isn't accepted by "br" is. One of the limitations of lib2to3 (and therefore YAPF) is that it requires the code to be well-formed. Here's what I saw:

>>> rb'hello world'
  File "<stdin>", line 1
    rb'hello world'
                  ^
SyntaxError: invalid syntax
>>> br'hello world'
'hello world'
>>> 

from yapf.

jab avatar jab commented on July 24, 2024
$ python3
Python 3.4.3 (default, Mar  1 2015, 15:44:16)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> rb'this is valid python3 syntax'
b'this is valid python3 syntax'

Useful for e.g. not having to escape backslashes in bytestrings.

from yapf.

bwendling avatar bwendling commented on July 24, 2024

Ah! My mistake. I was using 2.7.

from yapf.

bwendling avatar bwendling commented on July 24, 2024

Marking this as a bug, but I'm not sure what we can do here. Might be the same issue as yield from?

from yapf.

eliben avatar eliben commented on July 24, 2024

Yeah, I'll have to see what we do about places where lib2to3 fails. Maybe deeper monkey-patching will help

from yapf.

eliben avatar eliben commented on July 24, 2024

This is an upstream lib2to3 bug. Reported http://bugs.python.org/issue23894

Monkey patching this in lib2to3 is pretty complex -- I don't see this as very high priority at this time.

from yapf.

eliben avatar eliben commented on July 24, 2024

Adding a lib2to3 bug label.

from yapf.

bwendling avatar bwendling commented on July 24, 2024

Python 3 seems to have fixed this.

from yapf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.