raise ValueError("encoding only applicable for text mode")// normalize filepath and make dirs, as neededfilepath = os.path.realpath(os.path.expanduser(filepath))if make_dirs is True:
_make_dirs(filepath, mode)
elif mode.startswith("r") and not os.path.isfile(filepath):
raise OSError("file "{}" does not exist".format(filepath))
After Change
raise ValueError("encoding only applicable for text mode")// normalize filepath and make dirs, as neededfilepath = utils.to_path(filepath).resolve()if make_dirs is True:
_make_dirs(filepath, mode)
elif mode.startswith("r") and not filepath.is_file():
raise OSError("file "{}" does not exist".format(filepath))