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.

Title: os.stat() 's inappropriate behavior when dealing with a broken link in linux systems.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: hynek,, r.david.murray
Priority: normal Keywords:

Created on 2012-07-26 21:03 by, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg166519 - (view) Author: coder.maliubiao ( Date: 2012-07-26 21:03
the code:
import os,stat
mode=os.stat("a broken link file").st_mode
then i got :OSError: [Errno 2] No such file or directory.

why not just treat a broken link as something existing and don't report any error.
msg166533 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-07-27 02:23
Because we are doing what the linux stat call (and command) does .  See man stat.
msg166543 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-07-27 06:17
For the sake of completeness: what you're looking for is os.lstat.
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59666
2012-07-27 06:17:19hyneksetnosy: + hynek
messages: + msg166543
2012-07-27 02:23:28r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg166533

resolution: not a bug
stage: resolved
2012-07-26 21:03:20maliubiao@gmail.comcreate