mirror of
				https://github.com/python/cpython.git
				synced 2025-10-25 18:54:53 +00:00 
			
		
		
		
	bpo-37760: Constant-fold some old options in makeunicodedata. (GH-15129)
The `expand` option was introduced in 2000 in commit fad27aee1.
It appears to have been always set since it was committed, and
what it does is tell the code to do something essential.  So,
just always do that, and cut the option.
Also cut the `linebreakprops` option, which isn't consulted anymore.
			
			
This commit is contained in:
		
							parent
							
								
									def97c988b
								
							
						
					
					
						commit
						99d208efed
					
				
					 1 changed files with 20 additions and 24 deletions
				
			
		|  | @ -943,10 +943,7 @@ class UnicodeData: | |||
|     #  ISO-comment, uppercase, lowercase, titlecase, ea-width, (16) | ||||
|     #  derived-props] (17) | ||||
| 
 | ||||
|     def __init__(self, version, | ||||
|                  linebreakprops=False, | ||||
|                  expand=1, | ||||
|                  cjk_check=True): | ||||
|     def __init__(self, version, cjk_check=True): | ||||
|         self.changed = [] | ||||
|         table = [None] * 0x110000 | ||||
|         for s in UcdFile(UNICODE_DATA, version): | ||||
|  | @ -956,26 +953,25 @@ def __init__(self, version, | |||
|         cjk_ranges_found = [] | ||||
| 
 | ||||
|         # expand first-last ranges | ||||
|         if expand: | ||||
|             field = None | ||||
|             for i in range(0, 0x110000): | ||||
|                 s = table[i] | ||||
|                 if s: | ||||
|                     if s[1][-6:] == "First>": | ||||
|                         s[1] = "" | ||||
|                         field = s | ||||
|                     elif s[1][-5:] == "Last>": | ||||
|                         if s[1].startswith("<CJK Ideograph"): | ||||
|                             cjk_ranges_found.append((field[0], | ||||
|                                                      s[0])) | ||||
|                         s[1] = "" | ||||
|                         field = None | ||||
|                 elif field: | ||||
|                     f2 = field[:] | ||||
|                     f2[0] = "%X" % i | ||||
|                     table[i] = f2 | ||||
|             if cjk_check and cjk_ranges != cjk_ranges_found: | ||||
|                 raise ValueError("CJK ranges deviate: have %r" % cjk_ranges_found) | ||||
|         field = None | ||||
|         for i in range(0, 0x110000): | ||||
|             s = table[i] | ||||
|             if s: | ||||
|                 if s[1][-6:] == "First>": | ||||
|                     s[1] = "" | ||||
|                     field = s | ||||
|                 elif s[1][-5:] == "Last>": | ||||
|                     if s[1].startswith("<CJK Ideograph"): | ||||
|                         cjk_ranges_found.append((field[0], | ||||
|                                                  s[0])) | ||||
|                     s[1] = "" | ||||
|                     field = None | ||||
|             elif field: | ||||
|                 f2 = field[:] | ||||
|                 f2[0] = "%X" % i | ||||
|                 table[i] = f2 | ||||
|         if cjk_check and cjk_ranges != cjk_ranges_found: | ||||
|             raise ValueError("CJK ranges deviate: have %r" % cjk_ranges_found) | ||||
| 
 | ||||
|         # public attributes | ||||
|         self.filename = UNICODE_DATA % '' | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Greg Price
						Greg Price