diff options
| author | bwarsaw | 1999-01-05 23:03:43 +0000 |
|---|---|---|
| committer | bwarsaw | 1999-01-05 23:03:43 +0000 |
| commit | 2c32817b59f1c3e1d5db9897c8a646328955b06b (patch) | |
| tree | 94364afbb43fb869d4d260307e709748f9b536dc /Mailman/Utils.py | |
| parent | f462311f8863821e89b85219a59f39744d72499a (diff) | |
| download | mailman-2c32817b59f1c3e1d5db9897c8a646328955b06b.tar.gz mailman-2c32817b59f1c3e1d5db9897c8a646328955b06b.tar.zst mailman-2c32817b59f1c3e1d5db9897c8a646328955b06b.zip | |
reraise(): can now take an optional val argument, which is only used
when exc is not None.
open_ex(): Use reraise().
Diffstat (limited to 'Mailman/Utils.py')
| -rw-r--r-- | Mailman/Utils.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 522c6a0e0..c0e1fabf7 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -591,9 +591,13 @@ def IsAdministrivia(msg): -def reraise(exc=None): +def reraise(exc=None, val=None): """Use this function to re-raise an exception. + This implementation hides the differences between Python versions. + Optional exc is the exception type to raise. When exc is not None, + optional val is the exception value to raise. + """ # Python 1.5.2 # raise @@ -601,7 +605,7 @@ def reraise(exc=None): if exc is None: t, v, tb = sys.exc_info() raise t, v, tb - raise exc, None, sys.exc_info()[2] + raise exc, val, sys.exc_info()[2] def mkdir(dir, mode=02775): @@ -649,6 +653,6 @@ def open_ex(filename, mode='r', bufsize=-1, perms=0664): return fp # transform any os.errors into IOErrors except os.error, e: - raise IOError, e, sys.exc_info()[2] + reraise(IOError, e) finally: os.umask(ou) |
