error: bad escape \p at position 2
See original GitHub issueWhen i try this tracing-a-piece-of-code i get “error: bad escape \p at position 2” Here is my code
In [214]: a = 1
In [215]: b = 2
In [216]: with stackprinter.TracePrinter(style='darkbg2'):
...: c = a- b
...:
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-216-cd5f160fdc24> in <module>
1 with stackprinter.TracePrinter(style='darkbg2'):
----> 2 c = a- b
3
c:\program files\python36\lib\site-packages\stackprinter\tracing.py in __exit__(self, etype, evalue, tb)
97 return self
98
---> 99 def __exit__(self, etype, evalue, tb):
100 self.disable()
101 if etype is None:
c:\program files\python36\lib\site-packages\stackprinter\tracing.py in trace(self, frame, event, arg)
127 if 'call' in event:
128 callsite = frame.f_back
--> 129 self.show(callsite)
130 self.show(frame)
131 elif 'return' in event:
c:\program files\python36\lib\site-packages\stackprinter\tracing.py in show(self, frame, note)
147
148 filepath = inspect.getsourcefile(frame) or inspect.getfile(frame)
--> 149 if match(filepath, __file__):
150 return
151 elif match(filepath, self.suppressed_paths):
c:\program files\python36\lib\site-packages\stackprinter\utils.py in match(string, patterns)
12 elif patterns is None:
13 return False
---> 14 return any([bool(re.search(p, string)) for p in patterns])
15
16 def inspect_callable(f):
c:\program files\python36\lib\site-packages\stackprinter\utils.py in <listcomp>(.0)
12 elif patterns is None:
13 return False
---> 14 return any([bool(re.search(p, string)) for p in patterns])
15
16 def inspect_callable(f):
c:\program files\python36\lib\re.py in search(pattern, string, flags)
180 """Scan through string looking for a match to the pattern, returning
181 a match object, or None if no match was found."""
--> 182 return _compile(pattern, flags).search(string)
183
184 def sub(pattern, repl, string, count=0, flags=0):
c:\program files\python36\lib\re.py in _compile(pattern, flags)
299 if not sre_compile.isstring(pattern):
300 raise TypeError("first argument must be string or compiled pattern")
--> 301 p = sre_compile.compile(pattern, flags)
302 if not (flags & DEBUG):
303 if len(_cache) >= _MAXCACHE:
c:\program files\python36\lib\sre_compile.py in compile(p, flags)
560 if isstring(p):
561 pattern = p
--> 562 p = sre_parse.parse(p, flags)
563 else:
564 pattern = None
c:\program files\python36\lib\sre_parse.py in parse(str, flags, pattern)
853
854 try:
--> 855 p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
856 except Verbose:
857 # the VERBOSE flag was switched on inside the pattern. to be
c:\program files\python36\lib\sre_parse.py in _parse_sub(source, state, verbose, nested)
414 while True:
415 itemsappend(_parse(source, state, verbose, nested + 1,
--> 416 not nested and not items))
417 if not sourcematch("|"):
418 break
c:\program files\python36\lib\sre_parse.py in _parse(source, state, verbose, nested, first)
500
501 if this[0] == "\\":
--> 502 code = _escape(source, this, state)
503 subpatternappend(code)
504
c:\program files\python36\lib\sre_parse.py in _escape(source, escape, state)
399 if len(escape) == 2:
400 if c in ASCIILETTERS:
--> 401 raise source.error("bad escape %s" % escape, len(escape))
402 return LITERAL, ord(escape[1])
403 except ValueError:
error: bad escape \p at position 2
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
how to fix - error: bad escape \u at position 0
I dealt with a similar issue ( sre_constants.error: bad escape \p at position 1 ) and the solution was to import regex and...
Read more >Gotchas - Python re(gex)? - learnbyexample
Some RE engines match character literally if an escape sequence is not defined. Python raises an exception for such cases. Apart from sequences...
Read more >Can someone dumb this error (bad escape(end of pattern) ...
It looks like you are saving the result of the re.sub to line, which you then immediately overwrite with the next line.
Read more >Python Re Escape
This article is the ultimate guide to escape special characters in Python. ... that has not a special meaning, Python will throw a...
Read more >解决:error: bad escape \N at position 0
解决:error: bad escape \N at position 0 ... 很显然, info 这个字段的类型为 object 。所以我就寻思着,获取该列中的元素,将该列中的 \N 替换为 0 或者 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it has been fixed. Thank you~
Oh I should do like this