[Patches] [ python-Patches-462296 ] Add attributes to os.stat results

noreply@sourceforge.net noreply@sourceforge.net
Mon, 17 Sep 2001 10:57:02 -0700


Patches item #462296, was opened at 2001-09-17 10:57
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462296&group_id=5470

Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nick Mathewson (nickm)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add attributes to os.stat results

Initial Comment:
See bug #111481, and PEP 0042.  Both suggest that the
return values for os.{stat,lstat,statvfs,fstatvfs}
ought to be struct-like objects rather than simple tuples. 

With this patch, the os module will modify the
aformentioned functions so that their results still
obey the previous tuple protocol, but now have
read-only attributes as well.  In other words,
"os.stat('filename')[0]" is now synonymous with
"os.stat('filename').st_mode.

The patch also modifies test_os.py to test the new
behavior.

In order to prevent old code from breaking, these new
return types extend tuple.  They also use the new
attribute descriptor interface. (Thanks for
PEP-025[23], Guido!)

Backward compatibility:  Code will only break if it
assumes that type(os.stat(...)) == TupleType, or if it
assumes that os.stat(...) has no attributes beyond
those defined in tuple.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462296&group_id=5470