Open
Description
CircuitPython version
Adafruit CircuitPython 9.1.4 on 2024-09-17; Raspberry Pi Pico with rp2040
Code/REPL
a = b'A' * 32
print(a.count(b'A'))
print(a.count(65)) #A is ascii character 65
Behavior
The count function works with the byte string but not the integer. See:
32
Traceback (most recent call last):
File "code.py", line 3, in <module>
TypeError: can't convert 'int' object to str implicitly
Description
In contrast, with cPython 3.12.6 in win32, the count works with both the integer and the byte string:
>>> a = b'A' * 32
>>> a.count(b'A')
32
>>> a.count(65)
32
Additional information
https://docs.python.org/3/library/stdtypes.html#bytes.count states
The subsequence to search for may be any bytes-like object or an integer in the range 0 to 255.