-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
os.fspath is certain to crash when exception raised in __fspath__ #71699
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
When any exception is raised inside __fspath__, operations involving it like os.fspath, open are certain to crash. >>> import os
>>> class Test:
... def __fspath__(self):
... raise RuntimeError
...
>>> os.fspath(Test())
Segmentation fault (core dumped) Attach a patch to fix this. |
BTW, the code is also listed in PEP-519. So maybe that also needs to be fixed. |
Could you add tests? |
Ahh, adding tests is easy. But this seems to be just a careless omission, so maybe tests is not a must. |
This does also happen in make_zip too as it does not known about the current changes. https://bpaste.net/show/ff826604a5f0 |
nevermind the above traceback from it is a issue with the code that makes it try to copy the redist file from the v14 C++ runtime. |
I believe tests is that they should *especially* be in place for any previously found "careless omissions". If it has been done before, who is to say that it wouldn't happen again? |
I think such omissions are hard to predict and you won't know where is the omission until you encounter it. So if you don't know, how do you know what to put in the tests? And if it is encountered and fixed, such errors should not happen again. |
I think should be tests for following cases:
|
The test requests for the whole fspath are reasonable. I just don't want to add tests for these two lines.
|
True.
False. Such errors *will* happen again -- they are called regressions. In order to avoid those we add tests, and those tests serve several purposes:
In short: add tests; patches are not complete without them. |
Please don't. Moving tests around makes it harder for reviewers to see what Rewriting tests to do the same thing as before also takes more |
I have to explain for myself. First, I know tests *are* important. This is not the first time Second, maybe I cannot agree with your opinions in your last message. |
The reordering of the tests is unnecessary. Because you both changed the code *and* moved a test you have to be very careful to notice the change, otherwise it just looks like you cut-and-pasted the code to another location. Had you left the test method where it was and just simplified the code then it would be very obvious what you changed and reviewing it would be much easier. |
Thanks Brett, also others. Restore the moving around. |
New changeset 35bf83ff0828 by Brett Cannon in branch 'default': |
Thanks for the patch, Xiang! Only thing I changed were braces around the |
New changeset bb7686a555cc by Brett Cannon in branch 'default': |
Thanks for catching that, David. |
Brett, Misc/NEWS entry needs a # before issue number. |
Thanks, I'll fix it at some 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: