QUERY · ISSUE
bytes.find() differs from CPython
py-core
In Cpython (at least) I can find by integer using bytes.find(). Micropython doesn't allow this and only acceptsbytes as an argument to find.
Micropython:
>>> s = b'ABC'
>>> s.find(b'B')
1
>>> s.find(66)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert 'int' object to str implicitly
>>>
Desktop python:
>>> s = b'ABC'
>>> s.find(b'B')
1
>>> s.find(66)
1
Here is the check that's failing, but additional code would be needed to convert int (0..255) into byte.
https://github.com/micropython/micropython/blob/master/py/objstr.c#L693
This bug bit me deep in some QR encoding logic.
CANDIDATE · ISSUE
exec bytearray CPython inconsistency
py-core
Just found a minor CPython inconsistency with the way exec works.
On micropython:
exec('print(1)') # prints 1
exec(b'print(1)') # prints 1
exec(bytearray(b'print(1)')) # raises TypeError: can't convert 'bytearray' object to str implicitly
On CPython all versions work.