Skip to content

fcntl nicer polyfill #125568

@Lewiscowles1986

Description

@Lewiscowles1986

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions