-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
implement warnings module in C #44434
Comments
Re-implement the warnings module in C for speed and to reduce start up time. I don't remember the exact state of this patch. I'm sure it needs cleanup. IIRC the only thing missing feature-wise was processing command line arguments. Though I'm not entirely sure. It's been a while since I did it. I think I may have not used as many goto's in the code. I'm also thinking I didn't like it as the error handling was too complex. This definitely needs review. If anyone wants to finish this off, go for it. I'll probably return to it, but it won't be for a few weeks at the earliest. It would probably be good to make comments to remind me of what needs to be done. The new file should be Python/_warnings.c. I couldn't decide whether to put it under Python/ or Modules/. It seems some builtin modules are in both places. Maybe we should determine where the appropriate place is and move them all there. I couldn't figure out how to get svn to do a diff of a file that wasn't checked in. I think I filtered out all the unrelated changes. |
File Added: _warnings.c |
I have uploaded my touched up version of _warnings.c . I also have a It is still not complete, though. Some things are missing from |
I just tried Neal's version of _warnings.c and it has the same failures, |
I figured out why the tests are all failing; the C code does not call For instance, warn_explicit in the C code does not ever try to use a There is also the issue of the filters and once_registry also only be warnings.filter = []
... code ...
warnings.filter = original_filter That will not work with how it is implemented now as the C code only Could a descriptor be written so that when the Python code has the |
So the descriptor idea didn't work. Another idea is to have the C code that relies on attributes on warnings For instance, take warnings.filters. Initially it can be set to |
Attached is a new version of _warnings.c that checks to see if If Neal does a code review and OKs the approach then it can also be |
I think this is good enough for now. The approach will probably stand |
Regression test suite now passes. =) Had to add the support for when Couple things still left to implement. One is the second output line in In terms of differing semantics, file paths are different. Old way did In terms of testing, some _warnings-specific tests are needed. As Assigning to Neal to see if there is anything I missed in terms of todos |
I think Brett summarized the issues well. I can't think of anything |
This version of test_warnings has tests for _warnings.c. It currently But all the specified tests in my last comment have now been implemented. |
Attached is a diff against the trunk (including _warnings.c) that adds That leaves warn_explicit() and handling -W arguments on the TODO list. |
Implementing warn_explicit() is going to be troublesome with the new |
I see two ways of implementing the fetching of a source code line from One is to do it in Python. We have a function provided that can The other option is to rely on the fact that get_source() is supposed to |
The attached patch implements warn_explicit(), all in C. Tests are And -W still needs to be dealt with. |
Patch that has been brought up-to-date with r60968. No new work, though. |
Add tests for the 'line' argument to formatwarning() and showwarning(). |
Attached is what I think is a completely working version of warnings I think the fleshed out tests do a pretty good job of testing new code. Assigning to Neal to review (hopefully soon). |
On another note, the warnings module should be made to work with or |
I didn't realize this was waiting for me. You should have just checked pythonrun.c:
test_support/frozen: did you want the captured_std{out,err} change in Changes to Makefile.pre.in other than adding _warnings.o? I think this is good enough if it's working. How about checking it in |
After all the threats about checking in code that break stuff, I am not I will get to the changes when I can and then commit after the alpha. |
Neal's issues are addressed in this patch. I also finally filled out The attached patch is finished for CPython. I do want to go back and put |
Attached should have everything, including a pure Python fallback. As soon |
On Tue, Apr 1, 2008 at 6:14 AM, Brett Cannon <report@bugs.python.org> wrote:
I wasn't so worried about exposing it, I didn't like the name |
Committed in revision 62303. |
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: