Capture inputBox 'Cancel'

I’d like to capture when a user clicks Cancel on an inputBox. I would have thought this would work:

if retVal != None :
# do some stuff

However it seems to skip over that like it is returning something then I get an error:
‘TypeError: len() of unsized object’

Here’s the whole thing:

user = system.gui.inputBox("Enter username:","") if user != None : if len(user) > 0 : # get password pwd = system.gui.passwordBox("Enter password:","User: " + user) if len(pwd) > 0 : # verify ret =,pwd) if ret == 0 : # failed # system.gui.messageBox("No way!") return '' else : # passed #system.gui.messageBox("Yeah") #label = window.rootContainer.getComponent('lblUser') return user

Actually I I figured it out. Placing an else block and returning something fixed it. Just a bit of a misleading error I guess.