Infinite recursion error when debugging TaurusValueSpinBox
While debugging #707 (closed) we hit a strange recursion error if we try to put a print in TaurusValueSpinBox.validate()
The problem can be reproduced with the following snippet:
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.input import TaurusValueSpinBox
from taurus.external.qt import Qt
import taurus
class A(TaurusValueSpinBox):
def validate(self, input, pos):
val = self.lineEdit().validator()
taurus.debug('asd')
if val is None:
return Qt.QAbstractSpinBox.validate(self, input, pos)
return val.validate(input, pos)
app = TaurusApplication()
w = A()
model = 'sys/tg_test/1/double_scalar'
w.setModel(model)
When running it, I get:
Traceback (most recent call last):
File "/home/cpascual/.PyCharmCE2017.2/config/scratches/scratch_68.py", line 11, in validate
taurus.debug('asd')
File "/home/cpascual/src/taurus/lib/taurus/core/util/log.py", line 1019, in debug
return __getrootlogger().debug(msg, *args, **kw)
File "/home/cpascual/src/taurus/lib/taurus/core/util/log.py", line 1004, in __getrootlogger
return Logger.getLogger("TaurusRootLogger")
File "/home/cpascual/src/taurus/lib/taurus/core/util/log.py", line 656, in getLogger
cls.initRoot()
File "/home/cpascual/src/taurus/lib/taurus/core/util/log.py", line 526, in initRoot
return cls._getLogger()
File "/home/cpascual/src/taurus/lib/taurus/core/util/log.py", line 652, in _getLogger
logging.setLoggerClass(orig_logger_class)
File "/usr/lib/python2.7/logging/__init__.py", line 996, in setLoggerClass
if klass != Logger:
RuntimeError: maximum recursion depth exceeded in cmp
(...) (REPEATED SEVERAL TIMES)
By using git bisect, the problem seems to be starting with 69c39a61 and, indeed, if we comment out the call to setValue
in the first if
block of TaurusValueLineEdit.handleEvent()
(which was introduced with 69c39a61) this problem is gone.