Title: `os.sysconf()` rejects a configuration name given as an `__index__` object · Issue #9971 · RustPython/RustPython · GitHub
Open Graph Title: `os.sysconf()` rejects a configuration name given as an `__index__` object · Issue #9971 · RustPython/RustPython
X Title: `os.sysconf()` rejects a configuration name given as an `__index__` object · Issue #9971 · RustPython/RustPython
Description: Summary os.sysconf() accepts a configuration name only as a str or an exact int. Since 3.14, CPython accepts any object that defines __index__, so the same call raises TypeError on RustPython. Reproducer import os class I: def __init__(s...
Open Graph Description: Summary os.sysconf() accepts a configuration name only as a str or an exact int. Since 3.14, CPython accepts any object that defines __index__, so the same call raises TypeError on RustPython. Repr...
X Description: Summary os.sysconf() accepts a configuration name only as a str or an exact int. Since 3.14, CPython accepts any object that defines __index__, so the same call raises TypeError on RustPython. Repr...
Opengraph URL: https://github.com/RustPython/RustPython/issues/9971
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`os.sysconf()` rejects a configuration name given as an `__index__` object","articleBody":"## Summary\n\n`os.sysconf()` accepts a configuration name only as a `str` or an exact `int`. Since 3.14, CPython accepts any object that defines `__index__`, so the same call raises `TypeError` on RustPython.\n\n## Reproducer\n\n```python\nimport os\n\nclass I:\n def __init__(self, v):\n self.v = v\n def __index__(self):\n return self.v\n\nn = os.sysconf_names[\"SC_OPEN_MAX\"]\nprint(os.sysconf(n) == os.sysconf(\"SC_OPEN_MAX\"))\ntry:\n print(os.sysconf(I(n)) == os.sysconf(\"SC_OPEN_MAX\"))\nexcept Exception as e:\n print(type(e).__name__, e)\n```\n\n## Expected\n\nCPython 3.14.6:\n\n```\nTrue\nTrue\n```\n\n## Actual\n\nRustPython main (c4b303d):\n\n```\nTrue\nTypeError configuration names must be strings or integers\n```\n\n## Cause\n\n`SysconfName::try_from_object` ([posix.rs#L2911-L2933](https://github.com/RustPython/RustPython/blob/c4b303dcfae249899417e5b31de0f5c8629d27ec/crates/vm/src/stdlib/posix.rs#L2911-L2933)) downcasts to `PyInt` and otherwise expects a string. CPython's `conv_confname()` checks `PyIndex_Check()` and converts with `PyLong_AsInt()` ([posixmodule.c#L13712-L13719](https://github.com/python/cpython/blob/v3.14.6/Modules/posixmodule.c#L13712-L13719)), added in python/cpython#133096. CPython 3.13 still required an exact `int` there.\n\nThe practical impact may be small for now, since the common non-`int` `__index__` types such as NumPy integers are not available on RustPython yet.\n\n\u003csub>Drafted with help from Claude Code; I reviewed and checked it before posting.\u003c/sub>\n","author":{"url":"https://github.com/taxor03","@type":"Person","name":"taxor03"},"datePublished":"2026-11-19T16:21:42Z","url":"https://github.com/RustPython/RustPython/issues/9971"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:894b278c-234e-2bf9-f0a1-2f7ea57af631 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA8E:FC5BE:2DE7997:3D01BE8:6B01D40A |
| html-safe-nonce | 3bd6ae217ce5b642042d29ede65fc42d3bff3ddec98cb848993d772627de78cb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQThFOkZDNUJFOjJERTc5OTc6M0QwMUJFODo2QjAxRDQwQSIsInZpc2l0b3JfaWQiOiI2ODE1NjYzNjg4MDU0MzMwMzc5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e5d7abffeea4a11e96d6501f12e0638c7c0848db30798901d6556d4edee98958 |
| hovercard-subject-tag | issue:6494072102 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/9971/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9bc7f1d35ad15314049342f8452199cdcf3ccdba25cf113ea1819286a62a03fc/RustPython/RustPython/issues/9971 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9bc7f1d35ad15314049342f8452199cdcf3ccdba25cf113ea1819286a62a03fc/RustPython/RustPython/issues/9971 |
| og:image:alt | Summary os.sysconf() accepts a configuration name only as a str or an exact int. Since 3.14, CPython accepts any object that defines __index__, so the same call raises TypeError on RustPython. Repr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | taxor03 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width