Repository: RedHatInsights/insights-core

Issue:
'TypeError' object has no attribute 'tb_frame'
While fetching object details from insight inspect, getting kicked out from the ipython console with the following error. 
  'TypeError' object has no attribute 'tb_frame'

(gss-rules) ⌊gss-rules⌋»$ insights inspect insights.parsers.installed_rpms.InstalledRpms ~/scripts/rhel7_sosreport/

IPython Console Usage Info:

Enter 'InstalledRpms.' and tab to get a list of properties 
Example:
In [1]: InstalledRpms.<property_name>
Out[1]: <property value>

To exit ipython enter 'exit' and hit enter or use 'CTL D'

Starting IPython Interpreter Now 

In [1]: InstalledRpms
'TypeError' object has no attribute 'tb_frame'



Discussion:
I'm able to duplicate this problem in a clean env on RHEL 7 with python 3.6.  It appears to be a problem with the Jedi module.  You can temporarily work around the problem by not using any tab completion or by issuing the following command as the first command in ipython:
```python
%config Completer.use_jedi = False
```
Tab completion will work after this command is issued.

Here's an example:
```python
$ insights inspect insights.parsers.installed_rpms.InstalledRpms

IPython Console Usage Info:

Enter 'InstalledRpms.' and tab to get a list of properties 
Example:
In [1]: InstalledRpms.<property_name>
Out[1]: <property value>

To exit ipython enter 'exit' and hit enter or use 'CTL D'

Starting IPython Interpreter Now 

In [1]: InstalledRpms.get_max('bash')
Out[1]: 0:bash-4.2.46-34.el7

In [2]: %config Completer.use_jedi = False

In [3]: InstalledRpms.get_max('bash')
Out[3]: 0:bash-4.2.46-34.el7

In [4]: InstalledRpms.file_name
Out[4]: 'rpm_-qa_--qf_name_NAME_epoch_EPOCH_version_VERSION_release_RELEASE_arch_ARCH_installtime_INSTALLTIME_date_buildtime_BUILDTIME_vendor_VENDOR_buildhost_BUILDHOST_sigpgp_SIGPGP_pgpsig'
```
You can see the actual error by using the `run` function, I tried to use <TAB> completion at `input[8]`:
```python
$ ipython
Python 3.6.12 (default, Sep 15 2020, 12:49:50) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from insights import run

In [2]: from insights.parsers.installed_rpms import InstalledRpms

In [3]: broker = run(InstalledRpms)

In [4]: broker
Out[4]: <insights.core.dr.Broker at 0x7f5843d236d8>

In [5]: broker.keys()
Out[5]: dict_keys([<class 'insights.core.context.HostContext'>, <insights.core.spec_factory.simple_command object at 0x7f5843c1bd68>, insights.specs.Specs.installed_rpms, <class 'insights.parsers.installed_rpms.InstalledRpms'>])

In [6]: broker[InstalledRpms]
Out[6]: <insights.parsers.installed_rpms.InstalledRpms at 0x7f58439fefd0>

In [7]: rpms = broker[InstalledRpms]

In [8]: rpms.get_max('bash')
Traceback (most recent call last):
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/terminal/ptutils.py", line 113, in get_completions
    yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/terminal/ptutils.py", line 126, in _get_completions
    for c in completions:
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/core/completer.py", line 438, in _deduplicate_completions
    completions = list(completions)
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/core/completer.py", line 1818, in completions
    for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/core/completer.py", line 1862, in _completions
    full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/core/completer.py", line 2030, in _complete
    cursor_pos, cursor_line, full_text)
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/IPython/core/completer.py", line 1374, in _jedi_matches
    text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
  File "/home/bfahr/work/insights-core/.venv3/lib64/python3.6/site-packages/jedi/api/__init__.py", line 726, in __init__
    project=Project(Path.cwd()), **kwds)
TypeError: __init__() got an unexpected keyword argument 'column'
```
This is an [open issue](https://github.com/ipython/ipython/issues/12740) with IPython/Jedi.  I was able to fix the error by installing an older version of Jedi `pip install "jedi<0.18.0"`.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -70,7 +70,9 @@ def maybe_require(pkg):
     'ipython',
     'colorama',
     'jinja2',
-    'Pygments'
+    'Pygments',
+    'jedi<0.18.0'    # Open issue with jedi 0.18.0 and iPython <= 7.19
+                     # https://github.com/davidhalter/jedi/issues/1714
 ])
 
 testing = set([


Test patch: