New submission from Jairo Llopis <yajo....@gmail.com>:

Trying to read a directory on Linux raises the expected exception:

Python 3.9.1 (default, Jan 20 2021, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> pathlib.Path(".venv").read_text()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.9/pathlib.py", line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib64/python3.9/pathlib.py", line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
IsADirectoryError: [Errno 21] Is a directory: '.venv'


Doing the same on Windows raises a misleading permission error instead:

>>> import pathlib
>>> pathlib.Path(".venv").read_text()
Traceback (most recent call last):   
  File "<stdin>", line 1, in <module>
  File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py",
 line 1255, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py",
 line 1241, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py",
 line 1109, in _opener
    return self._accessor.open(self, flags, mode)
PermissionError: [Errno 13] Permission denied: '.venv'

----------
components: Windows
messages: 386103
nosy: Jairo Llopis, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Windows does not raise IsADirectoryError
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43095>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to