Skip to content
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

Redefining warnings.showwarning fails on python 3.6 #309

Closed
agabrown opened this issue Jul 17, 2017 · 2 comments
Closed

Redefining warnings.showwarning fails on python 3.6 #309

agabrown opened this issue Jul 17, 2017 · 2 comments

Comments

@agabrown
Copy link

agabrown commented Jul 17, 2017

I've installed galpy in a python3.6 environment and a simple "from galpy.orbit import Orbit" led to a whole stack of warnings which prevented galpy from working. This turns out to be due to the redefinition of warnings.showwarnings in the galpy/util/init.py code. I slight modified the _warning function as follows:

def _warning(
    message,
    category = galpyWarning,
    filename = '',
    lineno = -1,
    file = None,
    line = None):
    if issubclass(category,galpyWarning):
        print("galpyWarning: "+str(message))
    else:
        print(warnings.formatwarning(message,category,filename,lineno))

This fixes the problem that in python 3.6 the showwarning function expects 6 arguments instead of 4. On the last line formatwarning expects 4 or 5 arguments in python 3.6.

@jobovy
Copy link
Owner

jobovy commented Jul 17, 2017

Thanks, yes, I've known about this issue (#308) and it was already fixed in the branch fixwarnings, which has now been merged into master. Should work now if you install from master, please let me know if that resolves the issue.

@agabrown
Copy link
Author

Installing from master indeed resolves the issue. Thanks!

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

No branches or pull requests

2 participants