Skip to content

Commit

Permalink
Use the stat.S_ISREG check rather than try to cover all corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Mar 28, 2024
1 parent 72f4d4d commit 77778a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/xopen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ def _filepath_from_path_or_filelike(fileorpath: FileOrPath) -> str:
def _file_is_a_socket_or_pipe(filepath):
try:
mode = os.stat(filepath).st_mode
return stat.S_ISFIFO(mode) or stat.S_ISSOCK(mode) or stat.S_ISPORT(mode)
# Treat anything that is not a regular file as special
return not stat.S_ISREG(mode)
except (OSError, TypeError): # Type error for unexpected types in stat.
return False

Expand Down

0 comments on commit 77778a3

Please sign in to comment.