Donnerstag, 10. Dezember 2015

[Python+IPDB]

Tried to debug my code by inserting this line:
 import ipdb; ipdb.set_trace()
Got an error like this:
/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py:2707: AttributeError

 E           AttributeError: _dep_map

 Found a comment that said:
Ah, that means the real AttributeError is happening inside of the @property; the AttributeError being raised is after the fallback. Unfortunately, due to the way Python's attribute handling works, if there's an attribute error raised by a property getter, and the object has a __getattr__, then the real error is discarded and the __getattr__ is called instead.
So whatever error you're getting needs to be tracked down inside the @property;

Stepping through the code I found another error:
*** AttributeError: 'module' object has no attribute '_subx'
Which came from:
> /usr/lib/python2.7/re.py(155)sub()
-> return _compile(pattern, flags).sub(repl, string, count)

(Pdb) pattern
<_sre.SRE_Pattern object at 0xb6afb270>
(Pdb) flags
0
(Pdb) ccc = _compile(pattern, flags)
(Pdb) ccc
<_sre.SRE_Pattern object at 0xb6afb270>
(Pdb) repl
'\\1==\\2\\3'
(Pdb) string
'importlib'
(Pdb) count
0
(Pdb) ccc.sub(repl, string, count)
*** AttributeError: 'module' object has no attribute '_subx'
Something seemed wrong with the regex-lib. After removing the extra regex-lib via:
sudo python2.7 -mpip uninstall regex
I can use ipdb in my code again.


But was it really that regex-lib? On other code I could use ipdb without a problem. From the commented issue the solution was to change a custom parser-lib. So it may be something totally different for you. Look out for the exception-information from the _dep_map-property
@property
def _dep_map(self):
most probably from an exception inside the exception handling.

Keine Kommentare:

Kommentar veröffentlichen

[Review/Critic] UDock X - 13,3" LapDock

The UDock X - 13.3" LapDock is a combination of touch display, keyboard, touch-pad and battery. It can be used as an extension of vari...