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

fcntl nicer polyfill #125568

Closed
Lewiscowles1986 opened this issue Oct 16, 2024 · 2 comments
Closed

fcntl nicer polyfill #125568

Lewiscowles1986 opened this issue Oct 16, 2024 · 2 comments
Labels
type-feature A feature request or enhancement

Comments

@Lewiscowles1986
Copy link

Lewiscowles1986 commented Oct 16, 2024

Feature or enhancement

Proposal:

The following line errors on Windows

import fcntl

It's error is not helpful at all, but powers library code sysadmins use, such as sh:

To provide the minimum amount of confusion, I've written a polyfill:

https://github.com/Lewiscowles1986/python-fcntl

It writes to stderr and exits with non-zero error code, so that CI systems can know it doesn't work.

I've also tested it using sh on both mac and windows. Essentially it just gives a nicer error, which signposts the user to maybe use Docker (if they insist on using non linux or darwin systems).

All I'm shooting for here is a better error message, than an import error, for something folks have come to expect as part of the standard library (probably their fault, but I came across this with a user of mastodon complaining about Python, not sh and not fcntl)

https://mastodon.social/@mistersql/113314636889503344

I have asked PyPi to release the fcntl name to me, so that folks can pip install fcntl which I tested using a virtual environment using poetry, within the sh project itself to check it works.

But a nicer error for others without the shenanigans I went through might be better for all.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

@ZeroIntensity
Copy link
Member

Hi @Lewiscowles1986!

Unfortunately, I don't think this is a minor feature--please discuss it on Discourse first. A fair warning: you'll certainly get pushback there. In which case, that doesn't mean the idea is bad! In my experience, people very rarely shift opinions on discourse, I wouldn't bother with trying to get in arguments with them :)

A few notes about your polyfill implementation:

  • Printing to stderr and then calling exit is a bad idea for the standard library. Users don't really have a good way of preventing that message from coming up, other than disabling stderr entirely. Instead of printing, just raise an error.
  • I do like the idea of nicer import errors for OS-dependent libraries, but this should apply to all of those modules, not just fcntl--for example, curses and msvcrt have this problem as well. I would focus your proposal on discourse around that.

I'm going to close this for the time being. Let me know if you have any other questions, thanks!

@ZeroIntensity ZeroIntensity closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2024
@Lewiscowles1986
Copy link
Author

Thank you. I knew this would be the long and slow fix route internally. I'll now begin trying to search for similar issues on Discourse... If nobody hears from me again, I gave up 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants