GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46315: Use fopencookie() to avoid dup() in _PyTokenizer_FindEncodingFilename by tiran · Pull Request #32033 · python/cpython

Conversation

@tiran

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue46315

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tiran
bpo-46315: Use fdopencookie() to avoid dup() in _PyTokenizer_FindEnco…
6be12fc
…dingFilename
@tiran
tiran requested review from lysnikolaou and pablogsal as code owners March 21, 2022 19:07
@bedevere-bot bedevere-bot added the awaiting core review label Mar 21, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 21, 2022
@pablogsal pablogsal added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 21, 2022
@bedevere-bot

bedevere-bot commented 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

@pablogsal pablogsal Mar 21, 2022

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiran tiran Mar 21, 2022

Copy link
Copy Markdown
Member Author

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 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pablogsal pablogsal Mar 22, 2022

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tiran

tiran commented Mar 22, 2022

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal reviewed Mar 22, 2022
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal reviewed Mar 22, 2022
View reviewed changes
Comment thread Misc/NEWS.d/next/Core and Builtins/2022-03-21-20-05-10.bpo-46315.2QqFIC.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@tiran 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

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tiran added 3 commits March 22, 2022 12:56
@tiran
Make fopencookie path much shorter
e9efa50
@tiran
Remove whatsnew
0689719
@tiran
Shorten code even further
fa6ee5e
@tiran tiran added the skip news label Mar 22, 2022
@tiran
tiran merged commit 9b889b5 into python:main Mar 22, 2022
@bedevere-bot bedevere-bot removed the awaiting core review label Mar 22, 2022
@tiran tiran mentioned this pull request Oct 4, 2022
Add support for WebAssembly System Interface (wasm32-wasi) #90473
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pablogsal pablogsal pablogsal left review comments
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tiran @bedevere-bot @pablogsal @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.