Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add traceback information to exception #545

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

Merged
merged 5 commits into from
Nov 14, 2018

Conversation

testrunner123
Copy link
Contributor

@testrunner123 testrunner123 commented Sep 18, 2017

What does this implement/fix? Explain your changes.

Attach traceback information to newly created exception.

Does this close any currently open issues?

#542

Any other comments?

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@testrunner123
Copy link
Contributor Author

testrunner123 commented Sep 18, 2017

Tested with Python 3.5 64-bit on Windows 7 Pro. Example output is now:

GetPreferredSize
Traceback (most recent call last):
  File "t.py", line 29, in 
    main()
  File "t.py", line 24, in main
    form = StatusWindow()
  File "t.py", line 19, in __init__
    self.Controls.Add(_StagesGroup())
  File "t.py", line 14, in GetPreferredSize
    print("GetPreferredSize",xyz)
NameError: name 'xyz' is not defined

@codecov
Copy link

codecov bot commented Sep 18, 2017

Codecov Report

Merging #545 into master will increase coverage by 8.66%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #545      +/-   ##
==========================================
+ Coverage   68.55%   77.21%   +8.66%     
==========================================
  Files           1       62      +61     
  Lines         283     5596    +5313     
  Branches        0      897     +897     
==========================================
+ Hits          194     4321    +4127     
- Misses         89      982     +893     
- Partials        0      293     +293
Flag Coverage Δ
#setup_linux 69.42% <ø> (+0.87%) ⬆️
#setup_windows 76.39% <100%> (?)
Impacted Files Coverage Δ
src/runtime/exceptions.cs 80.35% <100%> (ø)
src/runtime/pyansistring.cs 100% <0%> (ø)
src/runtime/constructorbinder.cs 54.54% <0%> (ø)
src/runtime/methodbinder.cs 90.72% <0%> (ø)
src/runtime/Util.cs 37.5% <0%> (ø)
src/runtime/delegatemanager.cs 88.18% <0%> (ø)
src/runtime/eventbinding.cs 46.51% <0%> (ø)
src/runtime/pyiter.cs 77.27% <0%> (ø)
src/runtime/pynumber.cs 100% <0%> (ø)
src/runtime/interop27.cs 100% <0%> (ø)
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88d61a9...d80a8b9. Read the comment docs.

@den-run-ai
Copy link
Contributor

@testrunner123 there is one conflict in changelog.md and also no testing included.

@testrunner123
Copy link
Contributor Author

testrunner123 commented Sep 18, 2017

@denfromufa

I added line to CHANGELOG.md, but I can|t understand where conflict is. It was shown that merge automatically is possible.

@testrunner123
Copy link
Contributor Author

I have no write-access to pythonnet:master.

@testrunner123
Copy link
Contributor Author

Travis build is broken because it failed to install mono 4.x packages.

@den-run-ai
Copy link
Contributor

@testrunner123 those Mono + Travis CI issues have been fixed in @dmitriyse pull requests, which you can cherry pick into your commit.

@testrunner123
Copy link
Contributor Author

those Mono + Travis CI issues have been fixed in @dmitriyse pull requests, which you can cherry pick into your commit.

The problem is if I try to make a pull request to my branch or master then I am unable to do it. It says: everything is update. I am using web interface.

@den-run-ai
Copy link
Contributor

@testrunner123 you can only reliably cherry pick from git user interface, e.g. I use sourcetree and @vmuriart uses gitextensions:

https://github.com/gitextensions/gitextensions

Don't try to do it from command-line :)

Only web interface in gitlab supports cherry picking, GitHub and BitBucket do not support this.

@den-run-ai
Copy link
Contributor

@testrunner123 this should now pass the CI

@testrunner123
Copy link
Contributor Author

THX

@filmor
Copy link
Member

filmor commented Sep 22, 2017

This isn't quite right (it wasn't before, so you didn't introduce it but you can fix it :)). The documentation of PyErr_Restore states that you are giving up the references that you pass on, however, the PythonException object that the references stem from are Decrefd on Dispose. Best is probably to mark the PythonException instance as already disposed in this case.

@testrunner123
Copy link
Contributor Author

I guess you propose to call pe.PythonException.Restore() instead of Runtime.PyErr_Restore(). But this will also take GIL lock, that is already taken at this time ?

I just do not have enough knowledge about python interpreter to make a change and test it...
So may be you can do it right ? :)

@den-run-ai
Copy link
Contributor

@filmor can you clarify your suggestion a little bit more for @testrunner123 and for me?

@den-run-ai
Copy link
Contributor

@filmor i suggest to merge this PR and open a separate issue for your suggestion?

@filmor
Copy link
Member

filmor commented May 30, 2018

This PR decrefs an object that we hand over to another function, I don't think it's a good idea to merge it like this. I'll see whether I can do the needed changes.

@filmor
Copy link
Member

filmor commented Oct 17, 2018

So, from a review point of view, this is fine by me, we just need to fix the whole refcount situation, introducing another Incref before calling restore should be enough.

@filmor filmor added this to the 2.4.0 milestone Oct 18, 2018
@filmor filmor added the next label Oct 18, 2018
@filmor filmor merged commit 088580d into pythonnet:master Nov 14, 2018
@den-run-ai
Copy link
Contributor

@filmor what is going on today :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants