From 0149771997f0ea5d9c3b23e739de689cd6c5694b Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 18 Jan 2010 03:04:20 +0100 Subject: [PATCH] refine excludepath handling to treat entries with no path as matching --HG-- branch : trunk --- py/_code/code.py | 4 ++-- testing/code/test_excinfo.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/py/_code/code.py b/py/_code/code.py index 24f23d49e..846870e7f 100644 --- a/py/_code/code.py +++ b/py/_code/code.py @@ -293,8 +293,8 @@ class Traceback(list): code = x.frame.code codepath = code.path if ((path is None or codepath == path) and - (excludepath is None or (hasattr(codepath, 'relto') and - not codepath.relto(excludepath))) and + (excludepath is None or not hasattr(codepath, 'relto') or + not codepath.relto(excludepath)) and (lineno is None or x.lineno == lineno) and (firstlineno is None or x.frame.code.firstlineno == firstlineno)): return Traceback(x._rawentry) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 41ebdeded..306057eb4 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -114,8 +114,10 @@ class TestTraceback_f_g_h: excinfo = py.test.raises(ValueError, "p.pyimport().f()") basedir = py._pydir newtraceback = excinfo.traceback.cut(excludepath=basedir) - assert len(newtraceback) == 1 - assert newtraceback[0].frame.code.path == p + for x in newtraceback: + if hasattr(x, 'path'): + assert not py.path.local(x.path).relto(basedir) + assert newtraceback[-1].frame.code.path == p def test_traceback_filter(self): traceback = self.excinfo.traceback