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.

classification
Title: Implementation of major, minor and makedev
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, niemeyer, nnorwitz
Priority: normal Keywords: patch

Created on 2002-06-14 18:53 by niemeyer, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-2.3a0-st_rdev_pair.patch niemeyer, 2002-06-14 18:53
python-2.3a0-devicemacros.patch nobody, 2002-06-15 18:59 New approach to the needed features
Messages (9)
msg40306 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2002-06-14 18:53
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. 
msg40307 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-06-14 21:36
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.
msg40308 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2002-06-14 21:47
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. 
 
msg40309 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-06-14 22:02
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?
msg40310 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2002-06-14 22:23
Logged In: YES 
user_id=7887

I'll redo the patch with a test. 
 
Thanks! 
msg40311 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2002-06-15 19:04
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.   
msg40312 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-10-07 21:48
Logged In: YES 
user_id=21627

Is anything stopping this patch? If not, I'll apply it.
msg40313 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-10-08 19:17
Logged In: YES 
user_id=33168

I'm fine with checking in.
msg40314 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-10-10 14:28
Logged In: YES 
user_id=21627

Thanks for the patch. Committed as 

configure 1.345;
configure.in 1.356;
pyconfig.h.in 1.53;
libos.tex 1.98;
posixmodule.c 2.265;
History
Date User Action Args
2022-04-10 16:05:25adminsetgithub: 36750
2002-06-14 18:53:24niemeyercreate