catacomb/__init__.py: Don't try to convert text strings to `ByteString'.
[catacomb-python] / pock
diff --git a/pock b/pock
index ff62d8b..a980cbe 100644 (file)
--- a/pock
+++ b/pock
@@ -38,6 +38,10 @@ import catacomb as C
 ###--------------------------------------------------------------------------
 ### 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.
@@ -603,7 +607,7 @@ def check(pp, line):
   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):
   """
@@ -715,8 +719,9 @@ class PrimeProof (object):
         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
 
 ###--------------------------------------------------------------------------
@@ -1059,7 +1064,7 @@ pock [-qv] [-s SIEVEBITS] CMD ARGS...
 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 --------------------------------------------------