Since shelve.open() function may be used for reading, but also for writing files, when the user wants to read a shelve file by calling dataframe_with_info.read_file function, no errors are raised if the file does not exist and a new empty file is created.
This is a problem because usually this makes the function raise MultipleObjectsInFileError, but this does not explain the actual problem.
My proposal is to check if the file exists before opening it with shelve.open() function, or using theflag='r'for opening it in read-only mode (without the possibility of creating it when it does not exist), instead of the default flag='c'
Since
shelve.open()
function may be used for reading, but also for writing files, when the user wants to read a shelve file by callingdataframe_with_info.read_file
function, no errors are raised if the file does not exist and a new empty file is created. This is a problem because usually this makes the function raiseMultipleObjectsInFileError
, but this does not explain the actual problem.My proposal is to check if the file exists before opening it with shelve.open() function, or using the
flag='r'
for opening it in read-only mode (without the possibility of creating it when it does not exist), instead of the defaultflag='c'