File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11import ast
22import inspect
3+ import os
34import re
45import sys
56import traceback
@@ -343,10 +344,10 @@ def f(cur: TracebackType) -> Iterable[TracebackEntry]:
343344
344345 def cut (
345346 self ,
346- path : Optional [Union [Path , str ]] = None ,
347+ path : Optional [Union ["os.PathLike[str]" , str ]] = None ,
347348 lineno : Optional [int ] = None ,
348349 firstlineno : Optional [int ] = None ,
349- excludepath : Optional [Path ] = None ,
350+ excludepath : Optional ["os.PathLike[str]" ] = None ,
350351 ) -> "Traceback" :
351352 """Return a Traceback instance wrapping part of this Traceback.
352353
@@ -357,15 +358,17 @@ def cut(
357358 for formatting reasons (removing some uninteresting bits that deal
358359 with handling of the exception/traceback).
359360 """
361+ path_ = None if path is None else os .fspath (path )
362+ excludepath_ = None if excludepath is None else os .fspath (excludepath )
360363 for x in self :
361364 code = x .frame .code
362365 codepath = code .path
363- if path is not None and codepath != path :
366+ if path is not None and str ( codepath ) != path_ :
364367 continue
365368 if (
366369 excludepath is not None
367370 and isinstance (codepath , Path )
368- and excludepath in codepath .parents
371+ and excludepath_ in ( str ( p ) for p in codepath .parents ) # type: ignore[operator]
369372 ):
370373 continue
371374 if lineno is not None and x .lineno != lineno :
You can’t perform that action at this time.
0 commit comments