we-like-parsers / cpython

Here we work on integrating pegen into CPython; use branch 'pegen'
https://github.com/gvanrossum/pegen
Other
1 stars 0 forks source link

Handle raw strings with r and R in action helper #200

Closed isidentical closed 1 year ago

isidentical commented 1 year ago

This is hopefully the last fix we are going to need. Testing this (and the previous PRs) on top of PyPI now.

isidentical commented 1 year ago

Verified on the PyPI dataset, full behavioral roundtrip 👍🏻 (there are still empty "" string constants in joined str parts we can fix, but not a big problem).

isidentical commented 1 year ago

By the way @lysnikolaou, just to confirm, fstring-grammar-rebased-after-sprint is the latest branch right? (I've been merging my code there but now that I was looking into the branch list, there are a couple different rebase branches 🤔)

lysnikolaou commented 1 year ago

Yup, fstring-grammar-rebased-after-sprint was the latest one.

pablogsal commented 1 year ago

Verified on the PyPI dataset, full behavioral roundtrip 👍🏻 (there are still empty "" string constants in joined str parts we can fix, but not a big problem).

Where the empty strings are coming from?

isidentical commented 1 year ago

Where the empty strings are coming from?

Example:

f"""\
{1}
"""

Tree difference:

Module(
   body=[
      Expr(
         value=JoinedStr(
            values=[
               FormattedValue(
                  value=Constant(value=1),
                  conversion=-1),
               Constant(value='\n')]))],
   type_ignores=[])
Module(
   body=[
      Expr(
         value=JoinedStr(
            values=[
               Constant(value=''), # <========================
               FormattedValue(
                  value=Constant(value=1),
                  conversion=-1),
               Constant(value='\n')]))],