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

bpo-32381: Add _PyRun_AnyFileObject() #23723

Merged
merged 2 commits into from Dec 9, 2020
Merged

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Dec 9, 2020

pymain_run_file() no longer encodes the filename: pass the filename
as an object to the new _PyRun_AnyFileObject() function.

Add new private functions:

  • _PyRun_AnyFileObject()
  • _PyRun_InteractiveLoopObject()
  • _Py_FdIsInteractive()

https://bugs.python.org/issue32381

pymain_run_file() no longer encodes the filename: pass the filename
as an object to the new _PyRun_AnyFileObject() function.

Add new private functions:

* _PyRun_AnyFileObject()
* _PyRun_InteractiveLoopObject()
* _Py_FdIsInteractive()
@vstinner
Copy link
Member Author

vstinner commented Dec 9, 2020

test_ttk_guionly failed on Ubuntu. I re-run the jobs.

@vstinner vstinner merged commit a82f63f into python:master Dec 9, 2020
3 checks passed
@vstinner vstinner deleted the run_any branch Dec 9, 2020
@@ -313,17 +313,8 @@ pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
}
FILE *fp = _Py_wfopen(filename, L"rb");
if (fp == NULL) {
char *cfilename_buffer;
Copy link
Contributor

@kulikjak kulikjak Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this part removed? Because on Solaris (or any other platform where wchar_t values don't correspond to Unicode values) it no longer works. I found this when test_nonexisting_script (test.test_cmd_line_script.CmdLineTest) started failing with this:

...
  File "/builds/jkulik/buildbot-sources/components/python/pythonmaster/Python-3.10.0-a82f63f/Lib/subprocess.py", line 1018, in _translate_newlines
    data = data.decode(encoding, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 202: invalid continuation byte

But maybe I am missing something and the problem is somewhere else, that's why I'm asking.

Oracle Solaris and wchar_t: https://docs.oracle.com/cd/E36784_01/html/E39536/gmwkm.html

Copy link
Member Author

@vstinner vstinner Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I knew that someone will complain about that :-) I removed the code since it was ugly code that I wrote years ago. The correct fix is to rely on Python sys.stderr, not use C stderr. I wrote PR #23778 for that.

Copy link
Contributor

@kulikjak kulikjak Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I tried test_nonexisting_script with your new PR #23778 and it works again.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
pymain_run_file() no longer encodes the filename: pass the filename
as an object to the new _PyRun_AnyFileObject() function.

Add new private functions:

* _PyRun_AnyFileObject()
* _PyRun_InteractiveLoopObject()
* _Py_FdIsInteractive()
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.

None yet

4 participants