-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
The sys.float_repr_style should be read-only #128017
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
Comments
@skirpichev Are you working on it? Shall i take it? |
So final resolution is to improve the docs that |
No. I'm not sure yet how it should be solved.
Sure.
The "problem" actually span not only this variable in the sys module. You can "change" everything: >>> sys.maxsize
9223372036854775807
>>> sys.maxsize = 123
>>> sys.maxsize
123
>>> sys.int_info = "Spam"
>>> sys.int_info
'Spam' Current docs looks ok for me. But it seems some people are misguided by such possibility. Maybe some generic note might help them. |
https://peps.python.org/pep-0726/ was a good solution to this problem but it was rejected: https://discuss.python.org/t/pep-726-module-setattr-and-delattr/32640 |
I don't think that we can easily solve this issue and I suggest to close it. |
@vstinner, does it make sense for you as a documentation issue? |
Which kind of documentation addition are you thinking about? Add a note to each |
Yes, something like diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index dd6293c722..1aedb277ef 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -8,7 +8,9 @@
This module provides access to some variables used or maintained by the
interpreter and to functions that interact strongly with the interpreter. It is
-always available.
+always available. Except when explicitly noted otherwise, all variables are
+only for read access.
+
.. data:: abiflags |
Well,
|
And that fails to "when explicitly noted otherwise" :-) I'm not insist on exact wording as proposed above. Does it make sense for you? |
You can add this sentence if it matters to you:
|
…ule: sys are read-only, Unless explicitly stated otherwise
…GH-128887) (cherry picked from commit 313b96e) Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <thatiparthysreenivas@gmail.com>
…GH-128887) (cherry picked from commit 313b96e) Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <thatiparthysreenivas@gmail.com>
Issue fixed the in documentation by change 313b96e. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
It's possible to "change" the repr style for floats:
Of course, this has no effect, as this variable just shows build-time settings. That certainly can misguide people, e.g. see this: #128005 (comment)
It could be nice to make this variable read-only (unfortunately, PEP 726 was rejected and it's might be not so easy). Or, at least, improve docs to mention that it's intended to be read-only (we emphasize this e.g. for int_info fields).
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: