This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年07月06日 00:03 by sbt, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg164705 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2012年07月06日 00:03 | |
In Python 3.3 (but not earlier) os.stat() is documented to work with file descriptors. (os.path.exists() also works with fds since it is implemented in terms of os.stat(), although that is *not* documented.) However, on Windows if fd is not open then os.stat(fd) triggers an assertion error or crash: File: f:\dd\vctools\crt_bld\self_x86\crt\src\osfinfo.c Line: 316 Expression: (_osfile(fh) & FOPEN) Note that os.fstat() fails on Windows with OSError(EBADF, ...). |
|||
| msg164706 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2012年07月06日 00:10 | |
This can probably be fixed by using _PyVerify_fd(). |
|||
| msg164717 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2012年07月06日 07:49 | |
Many os functions started to accept file descriptors. I don't know how many are available on Windows, but IMO _PyVerify_fd() could be used for all of them; it's a no-op macro on Unix anyway. |
|||
| msg164719 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年07月06日 11:23 | |
New changeset 62b9bfbc3356 by Richard Oudkerk in branch 'default': Issue #15261: Stop os.stat(fd) crashing on Windows when fd not open. http://hg.python.org/cpython/rev/62b9bfbc3356 |
|||
| msg164720 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2012年07月06日 11:36 | |
> Many os functions started to accept file descriptors.
> I don't know how many are available on Windows...
On Windows os.stat() seems to be the only one:
>>> os.supports_fd
{<built-in function stat>}
|
|||
| msg164723 - (view) | Author: Larry Hastings (larry) * (Python committer) | Date: 2012年07月06日 14:16 | |
The 62b9bfbc3356 changeset does more than add the guard against invalid file handles; it also adds documentation to os.path.exists documenting that it now accepts path-as-int-fd. While this modification is fine in principle I would have preferred it was submitted separately. |
|||
| msg164732 - (view) | Author: Richard Oudkerk (sbt) * (Python committer) | Date: 2012年07月06日 15:55 | |
Sorry about that... |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:32 | admin | set | github: 59466 |
| 2012年07月06日 15:55:38 | sbt | set | messages: + msg164732 |
| 2012年07月06日 14:16:55 | larry | set | messages: + msg164723 |
| 2012年07月06日 12:45:27 | sbt | set | status: open -> closed resolution: fixed stage: needs patch -> resolved |
| 2012年07月06日 11:36:25 | sbt | set | messages: + msg164720 |
| 2012年07月06日 11:23:42 | python-dev | set | nosy:
+ python-dev messages: + msg164719 |
| 2012年07月06日 07:49:39 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc, larry messages: + msg164717 |
| 2012年07月06日 00:10:01 | sbt | set | messages: + msg164706 |
| 2012年07月06日 00:03:25 | sbt | create | |