Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Dec 9, 2020

Since pymain_run_command() uses UTF-8, pass PyCF_IGNORE_COOKIE
compiler flag to the parser.

And pymain_run_python() no longer propage compiler flags between
function calls.

https://bugs.python.org/issue32381

The coding cookie (ex: "# coding: latin1") is now ignored in the
command passed to the -c command line option.

Since pymain_run_command() uses UTF-8, pass PyCF_IGNORE_COOKIE
compiler flag to the parser.

pymain_run_python() no longer propages compiler flags between
function calls.
@vstinner
Copy link
Member Author

I added an unit test for the ignored coding cookie.

@lysnikolaou @pablogsal: Would you mind to review this change? Do you see any reason to propagate the compiler flags between functions calls? My expectation is that the original author didn't know how to pass compiler flags to PyRun functions, and so passed the same "cf" pointer all around, just to make PyRun functions happy.

@vstinner
Copy link
Member Author

cc @isidentical

@vstinner vstinner merged commit a124916 into python:master Dec 23, 2020
@vstinner vstinner deleted the compiler_flags branch December 23, 2020 18:17
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
The coding cookie (ex: "# coding: latin1") is now ignored in the
command passed to the -c command line option.

Since pymain_run_command() uses UTF-8, pass PyCF_IGNORE_COOKIE
compiler flag to the parser.

pymain_run_python() no longer propages compiler flags between
function calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants