FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46315: Use fopencookie() to avoid dup() in _PyTokenizer_FindEncodingFilename by tiran · Pull Request #32033 · python/cpython · GitHub

/ cpython Public

bpo-46315: Use fopencookie() to avoid dup() in _PyTokenizer_FindEncodingFilename - #32033

Merged
tiran merged 4 commits into
python:mainfrom
tiran:bpo-46315-fdopencookie
Mar 22, 2022
Merged

bpo-46315: Use fopencookie() to avoid dup() in _PyTokenizer_FindEncodingFilename#32033
tiran merged 4 commits into
python:mainfrom
tiran:bpo-46315-fdopencookie

Conversation

tiran commented Mar 21, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

pablogsal added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 21, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 6be12fc 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 21, 2022
Comment thread Parser/tokenizer.c Outdated
// cookie is just the fd
borrowed b;
b.fd = fd;
return fopencookie(b.cookie, "r", cookie_io);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fopencookie is a non-standard GNU extension. Is this available in all platforms targetted by web assembly? Does this need a configure check?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I had a configure check in my first version of the patch. I got rid of it because it makes no sense. Both WASI and Emscripten use musl libc as upper half of libc and it always provides fdopencookie.

I wish their was a more elegant way to solve the problem. _PyTokenizer_FindEncodingFilename uses a FILE pointer instead of a file descriptor.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ugh, I am honestly not very happy with the amount of extra code, but I understand why is needed.

tiran commented Mar 22, 2022

Copy link
Copy Markdown
Member Author

The failing tests on macOS ARM64 and FreeBSD are unrelated to my changes.

pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The code looks good to me, but I had no way to test it myself, so I am not formally approving. Feel free to land if you want though

tiran changed the title bpo-46315: Use fdopencookie() to avoid dup() in _PyTokenizer_FindEncodingFilename bpo-46315: Use fopencookie() to avoid dup() in _PyTokenizer_FindEncodingFilename Mar 22, 2022

tiran commented Mar 22, 2022

Copy link
Copy Markdown
Member Author

I can shorten the code. fopencookie handles NULL function pointers correctly. Our code only needs a read callback.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL