[Patches] [ python-Patches-569139 ] Implementation of major, minor and makedev

noreply@sourceforge.net noreply@sourceforge.net
Tue, 08 Oct 2002 12:17:10 -0700


Patches item #569139, was opened at 2002-06-14 14:53
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=569139&group_id=5470

Category: Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gustavo Niemeyer (niemeyer)
Assigned to: Martin v. Löwis (loewis)
Summary: Implementation of major, minor and makedev

Initial Comment:
As discussed in python-dev, st_rdev provides an integer, which 
usually needs to be translated in a (major, minor) pair before it's 
useful. There are no implementations of major() and minor() in the 
current library, and maybe there shouldn't be, since their functionality 
is not portable. 
 
This patch provides a portable way to access this information, by 
providing a new attribute to the os.stat() return tuple named 
st_rdev_pair. 

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-10-08 15:17

Message:
Logged In: YES 
user_id=33168

I'm fine with checking in.

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-10-07 17:48

Message:
Logged In: YES 
user_id=21627

Is anything stopping this patch? If not, I'll apply it.

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

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2002-06-15 15:04

Message:
Logged In: YES 
user_id=7887

I'm not sure if that's really the right way to implement the needed features    
for tarfile. Maybe including major, minor, and makedev could be the way to    
go.   
    
I'm sending the rationale to python-dev for discussion, and attaching a new   
patch with their implementations, instead of st_rdev_pair.   

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

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2002-06-14 18:23

Message:
Logged In: YES 
user_id=7887

I'll redo the patch with a test. 
 
Thanks! 

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-06-14 18:02

Message:
Logged In: YES 
user_id=33168

You are correct about the DECREF,
it is not necessary.

I'm not sure if any standards define
major/minor (that's why I asked).
What platform(s) did you test on?


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

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2002-06-14 17:47

Message:
Logged In: YES 
user_id=7887

I don't think a test is needed. If st_rdev is available, this information must 
be decodable by the system, and this is done by the major/minor pair, 
AFAIK. 
 
About the DECREF, I don't think it's needed. w's reference is stolen by v 
when PyStructSequence_SET_ITEM is run, and will be destroyed with v 
once it's DECREF'd. If that's not true, the whole logic is wrong in that 
function. 
 

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-06-14 17:36

Message:
Logged In: YES 
user_id=33168

Are major/minor guaranteed to exist?
Should a check be added to configure?

There is a missing DECREF.
In the last line of the patch to posixmodule.c,
there is if (PyErr_Occurred()) {

In that block, w needs to be DECREFed.
You can initialize w = NULL in the declaration,
then do an XDECREF in the error block.
That way you don't need to handle the error
creating w, if w != NULL, set the items in the tuple.

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

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