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 1
1
import ast
2
2
import inspect
3
+ import os
3
4
import re
4
5
import sys
5
6
import traceback
@@ -343,10 +344,10 @@ def f(cur: TracebackType) -> Iterable[TracebackEntry]:
343
344
344
345
def cut (
345
346
self ,
346
- path : Optional [Union [Path , str ]] = None ,
347
+ path : Optional [Union ["os.PathLike[str]" , str ]] = None ,
347
348
lineno : Optional [int ] = None ,
348
349
firstlineno : Optional [int ] = None ,
349
- excludepath : Optional [Path ] = None ,
350
+ excludepath : Optional ["os.PathLike[str]" ] = None ,
350
351
) -> "Traceback" :
351
352
"""Return a Traceback instance wrapping part of this Traceback.
352
353
@@ -357,15 +358,17 @@ def cut(
357
358
for formatting reasons (removing some uninteresting bits that deal
358
359
with handling of the exception/traceback).
359
360
"""
361
+ path_ = None if path is None else os .fspath (path )
362
+ excludepath_ = None if excludepath is None else os .fspath (excludepath )
360
363
for x in self :
361
364
code = x .frame .code
362
365
codepath = code .path
363
- if path is not None and codepath != path :
366
+ if path is not None and str ( codepath ) != path_ :
364
367
continue
365
368
if (
366
369
excludepath is not None
367
370
and isinstance (codepath , Path )
368
- and excludepath in codepath .parents
371
+ and excludepath_ in ( str ( p ) for p in codepath .parents ) # type: ignore[operator]
369
372
):
370
373
continue
371
374
if lineno is not None and x .lineno != lineno :
You can’t perform that action at this time.
0 commit comments