Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(169009)

Delta Between Two Patch Sets: Lib/sre_constants.py

Issue 22578: Add addition attributes to re.error
Left Patch Set: Created 5 years, 2 months ago
Right Patch Set: Created 5 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Doc/library/re.rst ('k') | Lib/sre_parse.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # 1 #
2 # Secret Labs' Regular Expression Engine 2 # Secret Labs' Regular Expression Engine
3 # 3 #
4 # various symbols used by the regular expression engine. 4 # various symbols used by the regular expression engine.
5 # run this script to update the _sre include files! 5 # run this script to update the _sre include files!
6 # 6 #
7 # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. 7 # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved.
8 # 8 #
9 # See the sre.py file for information on usage and redistribution. 9 # See the sre.py file for information on usage and redistribution.
10 # 10 #
(...skipping 14 matching lines...) Expand all
25 self.msg = msg 25 self.msg = msg
26 self.pattern = pattern 26 self.pattern = pattern
27 self.pos = pos 27 self.pos = pos
28 if pattern is not None and pos is not None: 28 if pattern is not None and pos is not None:
29 msg = '%s at position %d' % (msg, pos) 29 msg = '%s at position %d' % (msg, pos)
30 if isinstance(pattern, str): 30 if isinstance(pattern, str):
31 newline = '\n' 31 newline = '\n'
32 else: 32 else:
33 newline = b'\n' 33 newline = b'\n'
34 self.lineno = pattern.count(newline, 0, pos) + 1 34 self.lineno = pattern.count(newline, 0, pos) + 1
35 if self.lineno == 1: 35 self.colno = pos - pattern.rfind(newline, 0, pos)
36 self.colno = pos + 1 36 if newline in pattern:
37 else:
38 self.colno = pos - pattern.rindex(newline, 0, pos)
39 msg = '%s (line %d, column %d)' % (msg, self.lineno, self.colno) 37 msg = '%s (line %d, column %d)' % (msg, self.lineno, self.colno)
40 else: 38 else:
41 self.lineno = self.colno = None 39 self.lineno = self.colno = None
42 super().__init__(msg) 40 super().__init__(msg)
43 41
44 def linecol(doc, pos): 42 def linecol(doc, pos):
45 if isinstance(pattern, str): 43 if isinstance(pattern, str):
46 newline = '\n' 44 newline = '\n'
47 else: 45 else:
48 newline = b'\n' 46 newline = b'\n'
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE) 279 f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE)
282 f.write("#define SRE_FLAG_DEBUG %d\n" % SRE_FLAG_DEBUG) 280 f.write("#define SRE_FLAG_DEBUG %d\n" % SRE_FLAG_DEBUG)
283 f.write("#define SRE_FLAG_ASCII %d\n" % SRE_FLAG_ASCII) 281 f.write("#define SRE_FLAG_ASCII %d\n" % SRE_FLAG_ASCII)
284 282
285 f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX) 283 f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX)
286 f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL) 284 f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL)
287 f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET) 285 f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET)
288 286
289 f.close() 287 f.close()
290 print("done") 288 print("done")
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+