[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread Łukasz Langa
Change by Łukasz Langa : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___ P

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread miss-islington
miss-islington added the comment: New changeset 84494db41902774ea6ac72e5b308b429850bbf71 by Miss Islington (bot) in branch '3.10': bpo-41737: expand doc for NotADirectoryError (GH-27471) https://github.com/python/cpython/commit/84494db41902774ea6ac72e5b308b429850bbf71 -- __

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset b5f026112768eb0a06622263bdea86d7d85981c5 by Miss Islington (bot) in branch '3.9': bpo-41737: expand doc for NotADirectoryError (GH-27471) (GH-27577) https://github.com/python/cpython/commit/b5f026112768eb0a06622263bdea86d7d85981c5 -- ___

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 5.0 -> 6.0 pull_requests: +26082 pull_request: https://github.com/python/cpython/pull/27576 ___ Python tracker _

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset f7c23a99cd4f8179b6ba2cffaeb78b852c0f6488 by andrei kulakov in branch 'main': bpo-41737: expand doc for NotADirectoryError (GH-27471) https://github.com/python/cpython/commit/f7c23a99cd4f8179b6ba2cffaeb78b852c0f6488 -- nosy: +lukasz.langa

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread miss-islington
Change by miss-islington : -- pull_requests: +26083 pull_request: https://github.com/python/cpython/pull/27577 ___ Python tracker ___ __

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Eryk Sun
Eryk Sun added the comment: > On MacOS, I get Not a directory error on all 3 Confirmation on Linux and macOS suffices for "most POSIX systems", based on market share for desktops and servers. It would be nice to also confirm this for FreeBSD, AIX, HP-UX, and Solaris, but I suppose it isn't n

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Andrei Kulakov
Andrei Kulakov added the comment: Eryk: On MacOS, I get Not a directory error on all 3: NotADirectoryError: [Errno 20] Not a directory: 'spam' NotADirectoryError: [Errno 20] Not a directory: 'spam/' NotADirectoryError: [Errno 20] Not a directory: 'spam/eggs' --

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Eryk Sun
Eryk Sun added the comment: > It should be emphasized that it may happen on a **file operation** I think it's adequately covered by "attempts to open or traverse a non-directory file". The reader should know that opening "/path/to/file/somename.txt" requires traversing the components in the

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Danny Lin
Danny Lin added the comment: It should be emphasized that it may happen on a **file operation**... So at least be something like: "On some platforms, it may also be raised if a file operation involves an attempt to open or traverse a non-directory file as if it were a directory." --

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Andrei Kulakov
Andrei Kulakov added the comment: Eryk: sounds good, updated the PR. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Eryk Sun
Eryk Sun added the comment: I'd prefer a generic wording regarding the platform, and overall simpler phrasing without examples: "On some platforms, it may also be raised if an operation attempts to open or traverse a non-directory file as if it were a directory." The latter doesn't apply t

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Danny Lin
Danny Lin added the comment: @Andrei Kulakov: That statement is mainly for illustration that such behavior may vary across platforms. I use a rather vague statement as I'm not totally sure it applies if (and only if) running on POSIX. A more accurate statement is welcome as long as it's prov

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Andrei Kulakov
Andrei Kulakov added the comment: Danny: then it would be probably more useful to say "On POSIX systems, it will be raised when ...". I'm ambivalent on whether this is needed. Eryk: wdyt? -- ___ Python tracker

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Danny Lin
Danny Lin added the comment: @Andrei Kulakov: I was commenting on the previous version. The revised version (f2ae30b0de3c4ba1f16fc2a430cf22b447c062ed) seems ok to me. Another question: would it be better if we add "on some platforms" for the part that the error may raise on a file operation?

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Andrei Kulakov
Andrei Kulakov added the comment: (in fact, there is one example (for f-string exception) but the overall pattern is to just have reference type descriptions) -- ___ Python tracker _

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Andrei Kulakov
Andrei Kulakov added the comment: Danny: that would be inconsistent with the rest of the doc, it's written as a reference list for exceptions and none of them have examples currently.. It also seems fairly clear without an example. -- ___ Python t

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-30 Thread Danny Lin
Danny Lin added the comment: > I've put up a PR that expands the docs for NotADirectoryError here: > https://github.com/python/cpython/pull/27471/files Thank you. Wouldn't it be more clear if an example is provided? Like: (e.g. `/path/to` does not exist when running `open('/path/to/file')`)

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-29 Thread Andrei Kulakov
Andrei Kulakov added the comment: I've put up a PR that expands the docs for NotADirectoryError here: https://github.com/python/cpython/pull/27471/files -- ___ Python tracker __

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-07-29 Thread Andrei Kulakov
Change by Andrei Kulakov : -- nosy: +andrei.avk nosy_count: 3.0 -> 4.0 pull_requests: +25990 pull_request: https://github.com/python/cpython/pull/27471 ___ Python tracker ___ _

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Eryk Sun
Eryk Sun added the comment: Regarding documentation, builtin open() and the io and os modules generally do not provide information about platform-specific errors. But documenting the behavior for the NotADirectoryError exception itself may be useful considering it applies to many POSIX funct

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Danny Lin
Danny Lin added the comment: > Really? It's not obvious that finding a file would involve directory > operations? Not in some senses, and that's possibly why Windows does not raise NotADirectoryError in such case. I agree that it's a platform-specific implementation detail. However, there a

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Irit Katriel
Irit Katriel added the comment: > I don't think a general developer would expect that > open('/path/to/file/somename.txt') implies a directory operation, and it also > doesn't on Windows. Really? It's not obvious that finding a file would involve directory operations? In what sense does it

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Danny Lin
Danny Lin added the comment: I don't think a general developer would expect that open('/path/to/file/somename.txt') implies a directory operation, and it also doesn't on Windows. I suggest that a further notice be added to NotADirectoryError, such as: Raised when a directory operation (

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Irit Katriel
Irit Katriel added the comment: Hi Danny, I'm not saying that OSError and FileNotFoundError are equivalent. I'm saying that the open() API, as documented, raises OSError when opening the file fails. The way to check whether a file exists is to use os.path.exists(path) or os.path.isfile(pat

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Danny Lin
Danny Lin added the comment: By writing "except FileNotFoundError:", the intention is to catch an error when the file being opened is not found, and don't catch an error for other cases, such as an existing file without adequate permission. Writing "except OSError:" catches just too much cas

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-10-20 Thread Irit Katriel
Change by Irit Katriel : -- keywords: +patch pull_requests: +21774 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22818 ___ Python tracker ___ ___

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-09-21 Thread Irit Katriel
Irit Katriel added the comment: The documentation for open says "If the file cannot be opened, an OSError is raised." NotADirectoryError and FileNotFoundError are both OSErrors. So the correct way to write Danny's code snippet, according to the documentation, is: try: open('/pa

[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2020-09-11 Thread Terry J. Reedy
Change by Terry J. Reedy : -- title: Improper NotADirectoryError when opening a file under a fake directory -> Improper NotADirectoryError when opening a file in a fake directory ___ Python tracker _