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

Python docstrings mishandle apostrophes #246

Open
dbaggerman opened this issue Mar 28, 2021 · 0 comments
Open

Python docstrings mishandle apostrophes #246

dbaggerman opened this issue Mar 28, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@dbaggerman
Copy link
Collaborator

Describe the bug
Python docstrings containing an apostrophe end up in a weird state, continuing the docstring parsing beyond the end of the docstring and then ending up in a string state waiting for a closing single quote / apostrophe.

To Reproduce

#!/usr/bin/env python3

"""
Docstrings containing an apostrophe (') are handled incorrectly
The line above is counted as code despite being in the middle of a docstring.
The end of docstring flag seems to be changed to an apostrophe,
which means the next line will not exit the docstring.
"""
# Code containing single quotes will exit the docstring,
# but presuming the quotes are balanced the second
# quote will put us in string scanning mode.
if __name__ == '__main__':
    print('Hello, World!')
# Not counted as a comment

# ^ Not counted as a blank line
# Break out of string scanner with unbalanced single quote: '
    exit(0)

Expected behavior
Apostrophes / single quotes inside a docstring don't interrupt docstring parsing.

Desktop (please complete the following information):

  • Version 3.0
@boyter boyter added the bug Something isn't working label Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants