diff options
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 8527412..a53735b 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -517,6 +517,12 @@ def _parse(source, state, verbose, nested, first=False): setappend = set.append ## if sourcematch(":"): ## pass # handle character classes + if source.next == '[': + import warnings + warnings.warn( + 'Possible nested set at position %d' % source.tell(), + FutureWarning, stacklevel=nested + 6 + ) negate = sourcematch("^") # check remaining characters while True: @@ -529,6 +535,17 @@ def _parse(source, state, verbose, nested, first=False): elif this[0] == "\\": code1 = _class_escape(source, this) else: + if set and this in '-&~|' and source.next == this: + import warnings + warnings.warn( + 'Possible set %s at position %d' % ( + 'difference' if this == '-' else + 'intersection' if this == '&' else + 'symmetric difference' if this == '~' else + 'union', + source.tell() - 1), + FutureWarning, stacklevel=nested + 6 + ) code1 = LITERAL, _ord(this) if sourcematch("-"): # potential range @@ -545,6 +562,13 @@ def _parse(source, state, verbose, nested, first=False): if that[0] == "\\": code2 = _class_escape(source, that) else: + if that == '-': + import warnings + warnings.warn( + 'Possible set difference at position %d' % ( + source.tell() - 2), + FutureWarning, stacklevel=nested + 6 + ) code2 = LITERAL, _ord(that) if code1[0] != LITERAL or code2[0] != LITERAL: msg = "bad character range %s-%s" % (this, that) |