What is the behavior of the pickle.load() function when it is executed while…
2026
What is the behavior of the pickle.load() function when it is executed while the file pointer is at the End Of File (EOF)?
- A.
It returns None and automatically closes the file.
- B.
It returns NULL and automatically closes the file.
- C.
It raises an EOFError exception.
- D.
It automatically closes the file.
Attempted by 103 students.
Show answer & explanation
Correct answer: C
When pickle.load() is called, it expects serialized (pickled) data to read from the file. If the file pointer is already at the End Of File (EOF), there is no more data to read. In this situation, Python cannot load any object, so it raises an EOFError.