Skip to content

bpo-32381: Add _PyRun_AnyFileObject()#23723

Merged
vstinner merged 2 commits into
python:masterfrom
vstinner:run_any
Dec 9, 2020
Merged

bpo-32381: Add _PyRun_AnyFileObject()#23723
vstinner merged 2 commits into
python:masterfrom
vstinner:run_any

Conversation

@vstinner

@vstinner vstinner commented Dec 9, 2020

Copy link
Copy Markdown
Member

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

vstinner commented Dec 9, 2020

Copy link
Copy Markdown
Member Author

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

@vstinner vstinner merged commit a82f63f into python:master Dec 9, 2020
@vstinner vstinner deleted the run_any branch December 9, 2020 21:37
Comment thread Modules/main.c
}
FILE *fp = _Py_wfopen(filename, L"rb");
if (fp == NULL) {
char *cfilename_buffer;

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member Author

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
Copy Markdown
Contributor

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.

4 participants