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

gh-141510: Use frozendict for errno.errorcode by vstinner · Pull Request #144906 · python/cpython · GitHub

/ cpython Public

gh-141510: Use frozendict for errno.errorcode - #144906

Closed
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:frozendict_errno
Closed

gh-141510: Use frozendict for errno.errorcode#144906
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:frozendict_errno

Conversation

vstinner commented Feb 17, 2026
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

cc @Yhg1s

Comment thread Modules/errnomodule.c
add_errcode("ENOTCAPABLE", ENOTCAPABLE, "Capabilities insufficient");
#endif

PyObject *frozendict = PyFrozenDict_New(error_dict);

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

I think that we have to add new C API for frozendict with builder pattern.
This is inefficient for many people.

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

Well, frozendict is not widely used in C code yet. IMO it's too early to design an optimized API to build a new frozendict object. PyFrozenDict_New() should be good for now.

Yhg1s commented Feb 19, 2026

Copy link
Copy Markdown
Member

What's the rationale for using frozendict here? I don't think it's unreasonable at all for user/library code to want to add to errno.errorcode. We build the module contents from compile time constants, but we don't add any once the Python version is released. It's not at all unreasonable to want to add known errno values on older Python versions, or adding ones that weren't supported by the build environment.

Copy link
Copy Markdown
Member Author

Ah ok, in this case, I close my PR.

My rationale is that I wanted to disallow modifying existing error codes or adding new error codes. But you say that it's possible on purpose, so I prefer to close the PR.

vstinner closed this Feb 19, 2026

Yhg1s commented Feb 19, 2026

Copy link
Copy Markdown
Member

Just to be clear: I'm not saying it's possible on purpose, just that I think it is a useful property even if it wasn't on purpose, and I do think we have to consider that people are using the mutability. That's the case for any existing, exposed dict: it may not make sense to mutate it, but maybe we just don't see the cases where it does make sense. We have to consider whether the change is worth the potential breakage, so I think we need a good, real-world reason to replace the dict with a frozendict, not just a theoretical, common-sense one.

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.

3 participants


Back | FazBrowse Home | New Git URL