I have an override of QIntValidate that is giving me a python exception 
"maximum recursion depth exceeded".  The code works as I desire in PyQt4, but 
I wish to convert my project to using PySide.  I don't really mind if PySide 
has a different solution to the pass-by-reference conundrums of 
QValidate::validate, but I don't know how to implement this any other way.  
The PySide documentation [1] says that one can change either arg__1 or arg__2 
of PySide.QtGui.QValidator.validate(arg__1, arg__2), but that seems like non-
sense in the python world since the int arg__2 is immutable.

The code that I have is 
****
from PySide import QtGui,QtCore

class BlankIntValidator(QtGui.QIntValidator):
    def validate(self,input,pos):
        if input == "":
            return QtGui.QValidator.Acceptable, input, pos
        else:
            return QtGui.QIntValidator.validate(self,input,pos)

app = QtGui.QApplication([])
edit = QtGui.QLineEdit()
edit.setValidator(BlankIntValidator(edit))
edit.show()
app.exec_()
****
The desired operation is that the BlankIntValidator return Acceptable for 
blank strings as well as any integer string.  The observed exception is 
****
Exception RuntimeError: 'maximum recursion depth exceeded in 
__subclasscheck__' in <type 'exceptions.RuntimeError'> ignored
Traceback (most recent call last):
  File "test_blankable_int.py", line 12, in validate
    return QtGui.QIntValidator.validate(self,input,pos)
RuntimeError: maximum recursion depth exceeded while calling a Python object
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 48, in 
apport_excepthook
    if not enabled():
  File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 21, in 
enabled
    import re
RuntimeError: maximum recursion depth exceeded while calling a Python object

Original exception was:
Traceback (most recent call last):
  File "test_blankable_int.py", line 12, in validate
    return QtGui.QIntValidator.validate(self,input,pos)
RuntimeError: maximum recursion depth exceeded while calling a Python object
****

Any comments on this as a bug in PySide or a better way to write this would be 
much appreciated.

Thanks, Joel

[1] http://www.pyside.org/docs/pyside/PySide/QtGui/QValidator.html
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to