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

[BUG] value incorrectly displayed on error in __init__ #546

Closed
goretkin opened this issue Apr 7, 2020 · 2 comments
Closed

[BUG] value incorrectly displayed on error in __init__ #546

goretkin opened this issue Apr 7, 2020 · 2 comments
Labels

Comments

@goretkin
Copy link

goretkin commented Apr 7, 2020

Sorry this is a heavyweight reproducer. First I thought this was Julia-specific, but I did not see this behavior when running outside of Atom.

Details

  • Atom version: 1.44.0
  • Julia version: 1.3.1
  • OS: macOS 10.12.6
  • Package versions:
    • Atom.jl: v0.12.7
    • julia-client:
    • ink:

Steps to reproduce

module A
ENV["MPLBACKEND"]="bogus";

import PyCall
function __init__()
    @show length(methods(show))
    try
        PyCall.pyimport_conda("matplotlib", "matplotlib")
        # Once you have matplotlib installed, use this instead to go faster.
        # PyCall.pyimport("matplotlib")
    catch e
        show(e) # this is calling the right `show` method
        throw(e)
    end
end
end

Running the above file twice in Juno gives:

length(methods(show)) = 306
PyError (PyImport_ImportModule) <class 'ValueError'>
ValueError("Key backend: Unrecognized backend string 'bogus': valid strings are ['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']")
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 1317, in <module>
    rcParams['backend'] = os.environ.get('MPLBACKEND')
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 804, in __setitem__
    raise ValueError("Key %s: %s" % (key, str(ve)))
ERROR: InitError: PyCall.PyError("PyImport_ImportModule", PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000013ccea760), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000014c87c9b0), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000014c893640))
Stacktrace:
 [1] __init__() at /private/tmp/inittest.jl:14
during initialization of module A
WARNING: replacing module A.
306
PyError (PyImport_ImportModule) <class 'ValueError'>
ValueError("Key backend: Unrecognized backend string 'bogus': valid strings are ['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']")
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 1317, in <module>
    rcParams['backend'] = os.environ.get('MPLBACKEND')
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 804, in __setitem__
    raise ValueError("Key %s: %s" % (key, str(ve)))
ERROR: InitError: PyError (PyImport_ImportModule) <class 'ValueError'>
ValueError("Key backend: Unrecognized backend string 'bogus': valid strings are ['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']")
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 1317, in <module>
    rcParams['backend'] = os.environ.get('MPLBACKEND')
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/__init__.py", line 804, in __setitem__
    raise ValueError("Key %s: %s" % (key, str(ve)))

Stacktrace:
 [1] __init__() at /private/tmp/inittest.jl:14
during initialization of module A

I hope to draw your attention to the lines starting with "ERROR: InitError: " It is printed differently the first time (in a less helpful way). As far as I can tell, this was specific to __init__.

matplotlib is just an example that throws an error that has a specialized show method, which is obvious. Certainly any Python package that errors would do it. Sorry again for not having a slimmer reproducer.

@goretkin goretkin added the bug label Apr 7, 2020
@pfitzseb
Copy link
Member

pfitzseb commented Apr 7, 2020

Seems likely we're missing a bunch of invokelatests somewhere.

@pfitzseb
Copy link
Member

pfitzseb commented Apr 7, 2020

Fixed by JunoLab/Atom.jl#313.

@aviatesk aviatesk closed this as completed Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants