Skip to content

Commit e766968

Browse files
stsewdhumitos
andauthored
Build: Fix exceptions (#10616)
We were passing the path to the constructor, but that argument is actually the message. The message is already defined in the exception itself. --------- Co-authored-by: Manuel Kaufmann <[email protected]>
1 parent e11792b commit e766968

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

readthedocs/core/utils/filesystem.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def safe_open(
7676
)
7777

7878
if path.exists() and not path.is_file():
79-
raise FileIsNotRegularFile(path)
79+
raise FileIsNotRegularFile()
8080

8181
if not allow_symlinks and path.is_symlink():
8282
log.info("Skipping file becuase it's a symlink.")
83-
raise UnsupportedSymlinkFileError(path)
83+
raise UnsupportedSymlinkFileError()
8484

8585
# Expand symlinks.
8686
resolved_path = path.resolve()
@@ -89,17 +89,21 @@ def safe_open(
8989
file_size = resolved_path.stat().st_size
9090
if file_size > max_size_bytes:
9191
log.info("File is too large.", size_bytes=file_size)
92-
raise FileTooLarge(path)
92+
raise FileTooLarge()
9393

9494
if allow_symlinks and base_path:
9595
base_path = Path(base_path).absolute()
9696
if not resolved_path.is_relative_to(base_path):
9797
# Trying to path traversal via a symlink, sneaky!
9898
log.info("Path traversal via symlink.")
99-
raise SymlinkOutsideBasePath(path)
99+
raise SymlinkOutsideBasePath()
100100

101101
_assert_path_is_inside_docroot(resolved_path)
102102

103+
# The encoding is valid only if the file opened is a text file,
104+
# this function is used to read both types of files (text and binary),
105+
# so we can't specify the encoding here.
106+
# pylint: disable=unspecified-encoding
103107
return resolved_path.open(*args, **kwargs)
104108

105109

0 commit comments

Comments
 (0)