mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Optimize unicode_subtype_new(): don't encode to wchar_t and decode from wchar_t
Rewrite unicode_subtype_new(): allocate directly the right type.
This commit is contained in:
parent
e90fe6a8f4
commit
07ac3ebd7b
2 changed files with 81 additions and 43 deletions
|
@ -1010,10 +1010,13 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
class UnicodeSubclass(str):
|
||||
pass
|
||||
|
||||
self.assertEqual(
|
||||
str(UnicodeSubclass('unicode subclass becomes unicode')),
|
||||
'unicode subclass becomes unicode'
|
||||
)
|
||||
for text in ('ascii', '\xe9', '\u20ac', '\U0010FFFF'):
|
||||
subclass = UnicodeSubclass(text)
|
||||
self.assertEqual(str(subclass), text)
|
||||
self.assertEqual(len(subclass), len(text))
|
||||
if text == 'ascii':
|
||||
self.assertEqual(subclass.encode('ascii'), b'ascii')
|
||||
self.assertEqual(subclass.encode('utf-8'), b'ascii')
|
||||
|
||||
self.assertEqual(
|
||||
str('strings are converted to unicode'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue