Skip to content

Commit 77778a3

Browse files
committed
Use the stat.S_ISREG check rather than try to cover all corner cases
1 parent 72f4d4d commit 77778a3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/xopen/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ def _filepath_from_path_or_filelike(fileorpath: FileOrPath) -> str:
732732
def _file_is_a_socket_or_pipe(filepath):
733733
try:
734734
mode = os.stat(filepath).st_mode
735-
return stat.S_ISFIFO(mode) or stat.S_ISSOCK(mode) or stat.S_ISPORT(mode)
735+
# Treat anything that is not a regular file as special
736+
return not stat.S_ISREG(mode)
736737
except (OSError, TypeError): # Type error for unexpected types in stat.
737738
return False
738739

0 commit comments

Comments
 (0)