mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Issue #28760: Clean up and fix comments in PyUnicode_AsUnicodeEscapeString().
Patch by Xiang Zhang.
This commit is contained in:
		
						commit
						50911476f5
					
				
					 1 changed files with 4 additions and 10 deletions
				
			
		|  | @ -6118,12 +6118,7 @@ PyUnicode_DecodeUnicodeEscape(const char *s, | |||
|     return result; | ||||
| } | ||||
| 
 | ||||
| /* Return a Unicode-Escape string version of the Unicode object.
 | ||||
| 
 | ||||
|    If quotes is true, the string is enclosed in u"" or u'' quotes as | ||||
|    appropriate. | ||||
| 
 | ||||
| */ | ||||
| /* Return a Unicode-Escape string version of the Unicode object. */ | ||||
| 
 | ||||
| PyObject * | ||||
| PyUnicode_AsUnicodeEscapeString(PyObject *unicode) | ||||
|  | @ -6161,10 +6156,10 @@ PyUnicode_AsUnicodeEscapeString(PyObject *unicode) | |||
|     /* 4 byte characters can take up 10 bytes, 2 byte characters can take up 6
 | ||||
|        bytes, and 1 byte characters 4. */ | ||||
|     expandsize = kind * 2 + 2; | ||||
|     if (len > (PY_SSIZE_T_MAX - 2 - 1) / expandsize) { | ||||
|     if (len > PY_SSIZE_T_MAX / expandsize) { | ||||
|         return PyErr_NoMemory(); | ||||
|     } | ||||
|     repr = PyBytes_FromStringAndSize(NULL, 2 + expandsize * len + 1); | ||||
|     repr = PyBytes_FromStringAndSize(NULL, expandsize * len); | ||||
|     if (repr == NULL) { | ||||
|         return NULL; | ||||
|     } | ||||
|  | @ -6209,9 +6204,8 @@ PyUnicode_AsUnicodeEscapeString(PyObject *unicode) | |||
|                 *p++ = Py_hexdigits[ch & 0x000F]; | ||||
|             } | ||||
|         } | ||||
|         /* U+0000-U+00ff range: Map 16-bit characters to '\uHHHH' */ | ||||
|         /* U+0100-U+ffff range: Map 16-bit characters to '\uHHHH' */ | ||||
|         else if (ch < 0x10000) { | ||||
|             /* U+0100-U+ffff */ | ||||
|             *p++ = '\\'; | ||||
|             *p++ = 'u'; | ||||
|             *p++ = Py_hexdigits[(ch >> 12) & 0x000F]; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka