-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
sys.flags.__new__ crashes #57413
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
It's not possible (by intention) to instantiate a new instance of sys.flags. This is achieved by setting the "tp_new" slot to NULL (in Attached is a patch that fixes the crash and adds a test. |
I’m not sure it is useful to fix this bug. |
Why not? |
Because the class of sys.flags is an implementation detail. Most people won’t try to instantiate it, IMO. |
That's probably true, but IMHO it's not a valid reason to keep the buggy behavior. |
Why would we want to prevent users from creating new instances of FlagsType? |
You are right. Even if it’s an undocumented internal type, there is no reason not to fix it. There are plenty of similar crash fixes committed in the repo. |
Thanks for the patch. You should add the same tests for sys.version_info and sys.getwindowsversion. |
Thanks for reporting this and providing a patch, Trundle. The Python 3 patch didn't apply cleanly anymore, so I regenerated it and added tests for sys.version_info and sys.getwindowsversion.
import sys; sys.flags.__new__(type(sys.flags))
import sys; sys.version_info.__new__(type(sys.version_info))
import sys; sys.getwindowsversion().__new__(type(sys.getwindowsversion())) One important caveat is that while I confirmed the sys.getwindowsversion segfault on Windows, I don't have Visual Studio set up so I couldn't build and test the new test for sys.getwindowsversion (I ran the full test suite on OSX, where this test is skipped). |
Thanks for the patch, Jessica. It seems to work under Windows here. |
New changeset 7052fdd90a11 by Antoine Pitrou in branch '3.4': New changeset a14012352f65 by Antoine Pitrou in branch 'default': |
I've committed the patch to 3.4 and 3.5. I'm closing the issue, I don't think fixing 2.7 is important at this point. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: