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

"NameError: name 'reload' is not defined" on python 3 #50127

Open
mgomersbach opened this issue Oct 19, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@mgomersbach
Copy link
Contributor

commented Oct 19, 2018

Description of Issue/Question

Running Salt under py3 gives a NameError :

An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib64/python3.6/site-packages/salt/state.py", line 1913, in call
                  **cdata['kwargs'])
                File "/usr/lib64/python3.6/site-packages/salt/loader.py", line 1898, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib64/python3.6/site-packages/salt/states/pkg.py", line 1548, in installed
                  **kwargs)
                File "/usr/lib64/python3.6/site-packages/salt/states/pkg.py", line 521, in _find_install_targets
                  cur_pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)
                File "/usr/lib64/python3.6/site-packages/salt/modules/ebuild.py", line 426, in list_pkgs
                  pkgs = _vartree().dbapi.cpv_all()
                File "/usr/lib64/python3.6/site-packages/salt/modules/ebuild.py", line 68, in _vartree
                  portage = reload(portage)
              NameError: name 'reload' is not defined

"reload" is a Python 2 builtin and not available under Python 3.
Going through the code I could find 3 occurrences:

modules/ebuild.py:68: portage = reload(portage)
modules/ebuild.py:74: portage = reload(portage)
utils/virtualbox.py:145: reload(vboxapi)

Setup

Steps to Reproduce Issue

Versions Report

Salt Version:
           Salt: 2018.3.0-678-g84e2dcf
 
Dependency Versions:
           cffi: 1.11.5
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.6
   msgpack-pure: Not Installed
 msgpack-python: 0.5.1
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: Not Installed
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.6 (default, Sep 11 2018, 11:42:02)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.2
 
System Versions:
           dist: gentoo 2.4.1 
         locale: UTF-8
        machine: x86_64
        release: 4.18.11-gentoo
         system: Linux
        version: Gentoo Base System 2.4.1 
@averyfuentes9rs

This comment has been minimized.

Copy link

commented Nov 12, 2018

I have been running into this issue myself and I can report that @mgomersbach fix works on my gentoo installation, using python 3.6

Salt Version:
           Salt: 2018.3.3
 
Dependency Versions:
           cffi: 1.11.4
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.1
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 3.6.6
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.5 (default, Oct  3 2018, 09:09:51)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.2
 
System Versions:
           dist: gentoo 2.6 
         locale: UTF-8
        machine: x86_64
        release: 4.14.67-std530-amd64
         system: Linux
        version: Gentoo Base System 2.6 

However for my installation/version the patch is missing another occasion of
reload(portage) in salt/modules/portage_config.py

On my test machine I could verify that adapting commit to portage_config.py resolves the issue.

From a quick grep over this repo it seems portage_config.py is the only occasion of reload that is broken.

@mgomersbach

This comment has been minimized.

Copy link
Contributor Author

commented Nov 12, 2018

You are completely right! 😳
For some reason my first grep missed (branch 2017.7):

tests/unit/utils/test_path_join.py:130
tests/unit/utils/test_path_join.py:138 (in general the 'imp import')

salt/modules/portage_config.py:57

Should I squash them together in one PR or leave the test for someone else?

@mgomersbach

This comment has been minimized.

Copy link
Contributor Author

commented Nov 14, 2018

@averyfuentes9rs maybe this is not noticed because this already got merged, would you create a new bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.