12
12
13
13
# XXX: show string offset and offending character for all errors
14
14
15
+ import os
15
16
from ._constants import *
16
17
17
18
SPECIAL_CHARS = ".\\ [{()*+?^$|"
@@ -508,6 +509,8 @@ def _parse_sub(source, state, verbose, nested):
508
509
subpattern .append ((BRANCH , (None , items )))
509
510
return subpattern
510
511
512
+ _warn_skips = (os .path .dirname (__file__ ),)
513
+
511
514
def _parse (source , state , verbose , nested , first = False ):
512
515
# parse a simple pattern
513
516
subpattern = SubPattern (state )
@@ -557,7 +560,7 @@ def _parse(source, state, verbose, nested, first=False):
557
560
import warnings
558
561
warnings .warn (
559
562
'Possible nested set at position %d' % source .tell (),
560
- FutureWarning , stacklevel = nested + 5
563
+ FutureWarning , skip_file_prefixes = _warn_skips
561
564
)
562
565
negate = sourcematch ("^" )
563
566
# check remaining characters
@@ -580,7 +583,7 @@ def _parse(source, state, verbose, nested, first=False):
580
583
'symmetric difference' if this == '~' else
581
584
'union' ,
582
585
source .tell () - 1 ),
583
- FutureWarning , stacklevel = nested + 5
586
+ FutureWarning , skip_file_prefixes = _warn_skips
584
587
)
585
588
code1 = LITERAL , _ord (this )
586
589
if sourcematch ("-" ):
@@ -603,7 +606,7 @@ def _parse(source, state, verbose, nested, first=False):
603
606
warnings .warn (
604
607
'Possible set difference at position %d' % (
605
608
source .tell () - 2 ),
606
- FutureWarning , stacklevel = nested + 5
609
+ FutureWarning , skip_file_prefixes = _warn_skips
607
610
)
608
611
code2 = LITERAL , _ord (that )
609
612
if code1 [0 ] != LITERAL or code2 [0 ] != LITERAL :
0 commit comments