debugging elastic-recheck results in AttributeError: 'module' object has no attribute 'Cmd'

Bug #1522553 reported by Ramy Asselin
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack-Gate
New
Undecided
Unassigned

Bug Description

When trying to run elastic recheck in a debugger (pdb /pycharm) I get the following stack trace:

pydev debugger: process 12116 is connecting

Traceback (most recent call last):
  File "/home/stack/pycharm-community-5.0.1/helpers/pydev/pydevd.py", line 2403, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/stack/pycharm-community-5.0.1/helpers/pydev/pydevd.py", line 1794, in run
    launch(file, globals, locals) # execute the script
  File "/home/stack/pycharm-community-5.0.1/helpers/pycharm/utrunner.py", line 140, in <module>
    module = loadSource(a[0])
  File "/home/stack/pycharm-community-5.0.1/helpers/pycharm/utrunner.py", line 41, in loadSource
    module = imp.load_source(moduleName, fileName)
  File "/home/stack/elastic-recheck/elastic_recheck/tests/unit/test_stream.py", line 17, in <module>
    import fixtures
  File "/home/stack/venv/er/local/lib/python2.7/site-packages/fixtures/__init__.py", line 80, in <module>
    from fixtures.fixture import (
  File "/home/stack/venv/er/local/lib/python2.7/site-packages/fixtures/fixture.py", line 28, in <module>
    from testtools.compat import (
  File "/home/stack/venv/er/local/lib/python2.7/site-packages/testtools/__init__.py", line 59, in <module>
    from testtools.matchers._impl import (
  File "/home/stack/venv/er/local/lib/python2.7/site-packages/testtools/matchers/__init__.py", line 83, in <module>
    from ._doctest import (
  File "/home/stack/venv/er/local/lib/python2.7/site-packages/testtools/matchers/_doctest.py", line 7, in <module>
    import doctest
  File "/usr/lib/python2.7/doctest.py", line 99, in <module>
    import unittest, difflib, pdb, tempfile
  File "/usr/lib/python2.7/pdb.py", line 59, in <module>
    class Pdb(bdb.Bdb, cmd.Cmd):
AttributeError: 'module' object has no attribute 'Cmd'

Expected behavior: No AttributeError and debugger successfully loads

Revision history for this message
Ramy Asselin (ramy-asselin) wrote :

setting a breakpoint on pdb.py import cmd shows the reason for the error:

<module 'cmd' from '/home/stack/elastic-recheck/elastic_recheck/tests/unit/cmd/__init__.py'>

The projects 'cmd' package is getting loaded instead of the python built-in <module 'cmd' from '/usr/lib/python2.7/cmd.pyc'>.

Current workaround: delete the offending files:
elastic_recheck/tests/unit/cmd/__init__.py
elastic_recheck/cmd/__init__.py

Revision history for this message
Ramy Asselin (ramy-asselin) wrote :

Better workaround:

import sys
sys.path.insert(0, '/usr/lib/python2.7')

For some reason the system level package is at the end of the sys.path.
the first entry is '/home/asselin/git/elastic-recheck/elastic_recheck/tests/unit'

Not sure why that's happening. Doc says system path should be first [1]

[1] https://docs.python.org/2/tutorial/modules.html#the-module-search-path

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.