From: Zooko O'Whielacronx Date: Wed, 10 Dec 2008 14:10:57 +0000 (-0700) Subject: pyutil: assertutil: simplify handling of exception during formatting of precondition... X-Git-Url: https://git.rkrishnan.org/tahoe_css?a=commitdiff_plain;h=e29e4c04d9498927173057de0c93839459d2e4a0;p=tahoe-lafs%2Ftahoe-lafs.git pyutil: assertutil: simplify handling of exception during formatting of precondition message, and reduce dependency to just the Python Standard Library's logging module --- diff --git a/src/allmydata/util/assertutil.py b/src/allmydata/util/assertutil.py index 005ab16c..acd234ff 100644 --- a/src/allmydata/util/assertutil.py +++ b/src/allmydata/util/assertutil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2003-2006 Bryce "Zooko" Wilcox-O'Hearn +# Copyright (c) 2003-2008 Zooko Wilcox-O'Hearn # mailto:zooko@zooko.com # http://zooko.com/ # Permission is hereby granted, free of charge, to any person obtaining a @@ -11,8 +11,6 @@ Tests useful in assertion checking, prints out nicely formated messages too. from humanreadable import hr -from allmydata.util import log - def _assert(___cond=False, *___args, **___kwargs): if ___cond: return True @@ -47,13 +45,9 @@ def precondition(___cond=False, *___args, **___kwargs): if ___kwargs: msgbuf.append("%s: %s %s" % ((___kwargs.items()[0][0],) + tuple(map(hr, (___kwargs.items()[0][1], type(___kwargs.items()[0][1]),))))) msgbuf.extend([", %s: %s %s" % tuple(map(hr, (k, v, type(v),))) for k, v in ___kwargs.items()[1:]]) - except Exception, le: - log.msg("assertutil.precondition(): INTERNAL ERROR IN allmydata.util.assertutil. %s %s %s" % (type(le), repr(le), le.args,)) - log.err() - raise le except: - log.msg("assertutil.precondition(): INTERNAL ERROR IN allmydata.util.assertutil.") - log.err() + import logging + logging.exception("assertutil.precondition(): INTERNAL ERROR in allmydata.util.assertutil.") raise raise AssertionError, "".join(msgbuf)