Refactor to use traceback_frames() twice more
Switch from IOError to OSError, because, Python 3

There is no real IOError in Python 3.