diff options
Diffstat (limited to 'Lib/test/test_bigmem.py')
-rw-r--r-- | Lib/test/test_bigmem.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py index 7896748fe8..091893e7fe 100644 --- a/Lib/test/test_bigmem.py +++ b/Lib/test/test_bigmem.py @@ -418,18 +418,15 @@ class BaseStrTest: @bigmemtest(minsize=_2G, memuse=2) def test_translate(self, size): _ = self.from_latin1 - trans = { - ord(_('.')): _('-'), - ord(_('a')): _('!'), - ord(_('Z')): _('$'), - } SUBSTR = _('aZz.z.Aaz.') - if not isinstance(SUBSTR, str): - # Workaround the inexistence of bytes.maketrans() - chars = bytearray(range(256)) - for k, v in trans.items(): - chars[k] = ord(v) - trans = chars + if isinstance(SUBSTR, str): + trans = { + ord(_('.')): _('-'), + ord(_('a')): _('!'), + ord(_('Z')): _('$'), + } + else: + trans = bytes.maketrans(b'.aZ', b'-!$') sublen = len(SUBSTR) repeats = size // sublen + 2 s = SUBSTR * repeats |