###--------------------------------------------------------------------------
### Utilities.
+def _excval():
+ """Return the most recent exception object."""
+ return SYS.exc_info()[1]
+
class ExpectedError (Exception):
"""
I represent an expected error, which should be reported in a friendly way.
if p.nbits != nb:
raise ExpectedError('check failed: nbits(%s) = %d /= %d' % \
(label, p.nbits, nb))
- if VERBOSITY: print ';; %s = %d [%d]' % (label, p, nb)
+ if VERBOSITY: print(';; %s = %d [%d]' % (label, p, nb))
def setsievebits(pp, line):
"""
if step is not None:
me.addstep(step)
lastp = step.p
- except ExpectedError, e:
- raise ExpectedError('%s:%d: %s' % (file.name, lno, e.message))
+ except ExpectedError:
+ raise ExpectedError('%s:%d: %s' %
+ (file.name, lno, _excval().message))
return lastp
###--------------------------------------------------------------------------
## Prepare an option parser.
op = OP.OptionParser(
usage = '''\
-pock [-qv] CMD ARGS...
+pock [-qv] [-s SIEVEBITS] CMD ARGS...
gen NBITS
ll NBITS NSUBBITS
check [FILE]''',
if __name__ == '__main__':
prog = OS.path.basename(argv[0])
try: __main__()
- except ExpectedError, e: exit('%s: %s' % (prog, e.message))
- except IOError, e: exit('%s: %s' % (prog, e))
+ except ExpectedError: exit('%s: %s' % (prog, _excval().message))
+ except IOError: exit('%s: %s' % (prog, _excval()))
###----- That's all, folks --------------------------------------------------