mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape (also restructured a few things on the way to fixing #449000)
This commit is contained in:
		
							parent
							
								
									ab3b0343b8
								
							
						
					
					
						commit
						59b68656f8
					
				
					 4 changed files with 30 additions and 21 deletions
				
			
		|  | @ -647,9 +647,9 @@ def literal(literal, p=p): | |||
|             p.append((LITERAL, literal)) | ||||
|     sep = source[:0] | ||||
|     if type(sep) is type(""): | ||||
|         char = chr | ||||
|         makechar = chr | ||||
|     else: | ||||
|         char = unichr | ||||
|         makechar = unichr | ||||
|     while 1: | ||||
|         this = s.get() | ||||
|         if this is None: | ||||
|  | @ -693,14 +693,14 @@ def literal(literal, p=p): | |||
|                         break | ||||
|                 if not code: | ||||
|                     this = this[1:] | ||||
|                     code = LITERAL, char(atoi(this[-6:], 8) & 0xff) | ||||
|                     code = LITERAL, makechar(atoi(this[-6:], 8) & 0xff) | ||||
|                 if code[0] is LITERAL: | ||||
|                     literal(code[1]) | ||||
|                 else: | ||||
|                     a(code) | ||||
|             else: | ||||
|                 try: | ||||
|                     this = char(ESCAPES[this][1]) | ||||
|                     this = makechar(ESCAPES[this][1]) | ||||
|                 except KeyError: | ||||
|                     pass | ||||
|                 literal(this) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fredrik Lundh
						Fredrik Lundh