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.

Author mulugruntz
Recipients mulugruntz
Date 2021-05-28.10:19:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622197167.25.0.926188011866.issue44259@roundup.psfhosted.org>
In-reply-to
Content
I was trying to use https://github.com/NiklasRosenstein/pydoc-markdown to generate some doc for https://github.com/Mulugruntz/aiosubprocess

It was failing and for a while I thought I was doing something wrong. But when I did dig deeper, I realized that it was failing because I has a method named "exec".

The reason why I want to use "exec" is to make it obvious whether I'm executing the subprocess in shell mode or not (there's also a "shell" method).

As we can see here https://docs.python.org/3.9/reference/lexical_analysis.html#keywords

"exec" is not reserved.

Moreover, it's pretty counterintuitive that the code parses and runs correctly (cpython 3.9.5) but the lib2to3 parser crashes.

See below a working example:

```python
from lib2to3 import pygram, pytree
from lib2to3.pgen2 import driver
from lib2to3.pgen2.parse import ParseError

grammar = pygram.python_grammar.copy()
driver = driver.Driver(grammar, convert=pytree.convert)

strings = [
    "def fname(): pass",
    "def exec(): pass",
    """
class C:
    def exec(self): pass""",
]

for s in strings:
    try:
        driver.parse_string(s + '\n')
    except ParseError as pe:
        print("It fails:", s)
    else:
        print("It works:", s)

```

```shell
It works: def fname(): pass
It fails: def exec(): pass
It fails: 
class C:
    def exec(self): pass
```
History
Date User Action Args
2021-05-28 10:19:27mulugruntzsetrecipients: + mulugruntz
2021-05-28 10:19:27mulugruntzsetmessageid: <1622197167.25.0.926188011866.issue44259@roundup.psfhosted.org>
2021-05-28 10:19:27mulugruntzlinkissue44259 messages
2021-05-28 10:19:26mulugruntzcreate