PythonExtra/tests/io/file_readinto.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
267 B
Python
Raw Permalink Normal View History

b = bytearray(30)
f = open("data/file1", "rb")
print(f.readinto(b))
print(b)
f = open("data/file2", "rb")
print(f.readinto(b))
print(b)
2015-12-23 23:37:02 +01:00
# readinto() on writable file
f = open("data/file1", "ab")
2015-12-23 23:37:02 +01:00
try:
f.readinto(bytearray(4))
except OSError:
print("OSError")