From bbe78d78149a72a617e206aa2e0750a78ffa74e3 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 16 Apr 2009 00:09:50 -0400 Subject: [PATCH] Fix warnings regarding warning recording. (how peculiarly recursive) --- src/log.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/log.py b/src/log.py index e6d52e7..94f4a7f 100644 --- a/src/log.py +++ b/src/log.py @@ -275,12 +275,21 @@ class LogManager(object): def capture_warnings(self, enable=True): # FIXME warning capture on multiple processors + def _showwarning(message, category, filename, lineno, file=None, line=None): + self.old_showwarning(message, category, filename, lineno, file, line) + + if (self.db_conn is not None + and self.schema_version >= 1 + and self.mode == "w"): + self.db_conn.execute("insert into warnings values (?,?,?,?,?)", + (self.tick_count, str(message), str(category), filename, lineno)) + import warnings if enable: if self.old_showwarning is None: pass self.old_showwarning = warnings.showwarning - warnings.showwarning = self._showwarning + warnings.showwarning = _showwarning else: raise RuntimeError, "Warnings capture was enabled twice" else: @@ -290,15 +299,6 @@ class LogManager(object): warnings.showwarning = self.old_showwarning self.old_showwarning = None - def _showwarning(self, message, category, filename, line): - self.old_showwarning(message, category, filename, line) - - if (self.db_conn is not None - and self.schema_version >= 1 - and self.mode == "w"): - self.db_conn.execute("insert into warnings values (?,?,?,?,?)", - (self.tick_count, message.message, str(category), filename, line)) - def _load(self): if self.mpi_comm and self.mpi_comm.rank != self.head_rank: return -- GitLab