Firstly i want to thank you @lolgrep, this is no doubt the huge book which is gave to me, a kind of noob in iOS development, a huge amount of knowledge about whole low level technology stack, not only iOS debugging.
So back to deal: in the Chapter 20 on the page 262 there is try/except python expression in the code. Here’s that part:
try: #5
(options, args) = parser.parse_args(command_args)
except:
result.SetError(parser.usage)
return
Later you’ve described such try/catch as required due the parsing could be error-prone, so it could crash lldb either debugging application.
So in your code there’s no type of Exception has been provided. On the other hand i’m working with your book in Sublime text editor with anaconda plugin installed and turned on pep8 autocheking. And pep8 requires to set up type of Exception in the code explicitly. So i’ve tried to do so and firstly were failed.
Long story shorts, i’ve to debug with pdb optparse module to understand why the hell every inherited Exception class (including itself) fail to send control flow to the exception line and why the empty “except:” working correct simultaneously.
So the reason is that the optparse module don’t raise the exception in case of wrong option input. It sends sys.exit code in that case.
So this thing have two possible consequences:
- There’s no need try/except expression in the bar script, coz the optparse module don’t raise an exception it sends sys exit which shut down main script either. And in case of exception there’s happening double output in lldb console about the option error.
- To follow the pep8 there should to explicitly declare BaseException (which as i know now responsible to handle sys.exit’s, thanks to that script) and raise it in the exception expression instead of your script text. Like this, for example.
except BaseException as e:
raise e
In any case this thing is not a big deal, so posting this i’m firstly want to discuss this point and hear some clever thoughts about it.