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
AST parsing in python 2 with encoding and shebang #3750
Conversation
# Workaround for https://bugs.python.org/issue22221 | ||
lines_without_headers = [] | ||
lines = content.splitlines(True) | ||
for line in lines: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not enough to remove the # encoding
line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it later in the file to be able to parse/evaluate it... it can have non-ascii chars (and it reminds me that I need to add that in the test file! Thanks!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it already has non-ascii chars... there are several ¡Ñandú!
as authors... 😆
* fix issue conan-io#3749 reported by @hanickadot * do not split twice if not py2 * if there aren't headers, do not add a blank line * handle blank lines at the end of file
Changelog: Bugfix: AST parsing of
conanfile.py
with shebang and encoding header lines was failing in python 2. This fix also allows non-ascii chars inconanfile.py
if proper encoding is declared.