[pypy-commit] pypy py3.5: Add another failing test about 'bytes([i])'
arigo
pypy.commits at gmail.com
Wed Nov 30 08:20:08 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88760:65618280cf6c
Date: 2016-11-30 14:19 +0100
http://bitbucket.org/pypy/pypy/changeset/65618280cf6c/
Log: Add another failing test about 'bytes([i])'
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -5,14 +5,35 @@
class TestString(BaseTestPyPyC):
+
+ def test_python3_missing_bchr(self):
+ # Check that 'bytes([i])' is special-cased into something
+ # efficient, as Python 3.5 doesn't have a bchr() function or
+ # anything more direct.
+ def main(n):
+ i = 0
+ result = b''
+ while i < n:
+ c = bytes([i])
+ result += c
+ i += 1
+ return i
+ log = self.run(main, [255])
+ assert log.result == 255
+ loop, = log.loops_by_filename(self.filepath)
+ assert loop.match("""
+ #...
+ --TICK--
+ jump(..., descr=...)
+ """)
+
def test_lookup_default_encoding(self):
def main(n):
i = 0
letters = b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- letters = [b'%c' % n for n in letters] # list of single-char bytes
uletters = u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
while i < n:
- c = letters[i % len(uletters)]
+ c = bytes([letters[i % len(uletters)]])
i += (c.decode() == uletters[i % len(uletters)])
return i
More information about the pypy-commit
mailing list