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

UnboundLocalError: local variable 'img_path' referenced before assignment #4127

Closed
bdrung opened this issue Feb 9, 2017 · 3 comments
Closed

Comments

@bdrung
Copy link
Contributor

bdrung commented Feb 9, 2017

Description of your problem

The Ubuntu Error Tracker has been receiving reports about a problem regarding spyder. This problem was most recently seen with package version 3.0.2+dfsg1-2, the problem page at https://errors.ubuntu.com/problem/f4a67211f66fb239047b33781abfae6849af207a contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports.
If you do not have access to the Ubuntu Error Tracker you can request it at http://forms.canonical.com/reports/.

Traceback (most recent call last):
  File "/usr/bin/spyder3", line 3, in <module>
    start.main()
  File "/usr/lib/python3/dist-packages/spyder/app/start.py", line 103, in main
    from spyder.app import mainwindow
  File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 120, in <module>
    SPLASH = QSplashScreen(QPixmap(get_image_path('splash.svg'), 'svg'))
  File "/usr/lib/python3/dist-packages/spyder/config/base.py", line 212, in get_image_path
    return osp.abspath(osp.join(img_path, default))
UnboundLocalError: local variable 'img_path' referenced before assignment

The relevant code (taken from version 3.1.2+dfsg1-1):

def get_image_path(name, default="not_found.png"):
    """Return image absolute path"""
    for img_path in IMG_PATH:
        full_path = osp.join(img_path, name)
        if osp.isfile(full_path):
            return osp.abspath(full_path)
    if default is not None:
        return osp.abspath(osp.join(img_path, default))

The problem: When IMG_PATH is empty and default is defined, img_path is not defined and python will crash.

Versions and main components

  • Spyder Version: 3.0.2+dfsg1-2
  • Python Version: 3.5.1-4
  • Operating system: Ubuntu 17.04 (zesty)
@ccordoba12 ccordoba12 added this to the v3.1.3 milestone Feb 9, 2017
@ccordoba12
Copy link
Member

ccordoba12 commented Feb 9, 2017

We can fix it in Spyder 3.1.3 and you can backport the fix to the Ubuntu packages. Is that fine for you?

@bdrung
Copy link
Contributor Author

bdrung commented Feb 9, 2017

Yes, that's fine.

@ccordoba12
Copy link
Member

@dalthviz, please work on this one.

@ccordoba12 ccordoba12 changed the title spyder3: UnboundLocalError: local variable 'img_path' referenced before assignment UnboundLocalError: local variable 'img_path' referenced before assignment Feb 10, 2017
ccordoba12 added a commit that referenced this issue Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants