[issue11458] tarfile with socket incompatability

2011-03-10 Thread Alex Leach

Alex Leach beamesle...@gmail.com added the comment:

Thanks! =D

On Thu, Mar 10, 2011 at 3:46 AM, R. David Murray rep...@bugs.python.orgwrote:


 R. David Murray rdmur...@bitdance.com added the comment:

 I believe you are looking for mode 'r|'.

 --
 nosy: +r.david.murray
 resolution:  - works for me
 stage:  - committed/rejected
 status: open - closed

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue11458
 ___


--
Added file: http://bugs.python.org/file21069/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11458
___Thanks! =Dbrbrdiv class=gmail_quoteOn Thu, Mar 10, 2011 at 3:46 AM, R. 
David Murray span dir=ltrlt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span 
wrote:brblockquote class=gmail_quote style=margin: 0pt 0pt 0pt 0.8ex; 
border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;
br
R. David Murray lt;a 
href=mailto:rdmur...@bitdance.com;rdmur...@bitdance.com/agt; added the 
comment:br
br
I believe you are looking for mode #39;r|#39;.br
br
--br
nosy: +r.david.murraybr
resolution:  -gt; works for mebr
stage:  -gt; committed/rejectedbr
status: open -gt; closedbr
divdiv/divdiv class=h5br
___br
Python tracker lt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br
lt;a href=http://bugs.python.org/issue11458; 
target=_blankhttp://bugs.python.org/issue11458/agt;br
___br
/div/div/blockquote/divbr
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11458] tarfile with socket incompatability

2011-03-09 Thread Alex Leach

New submission from Alex Leach beamesle...@gmail.com:

Hi,

I'm trying to parse the contents of tar archives (.tgz) on the fly, and failing 
to do so. The tar archives in question have directory hierarchies, and only if 
a TarInfo object is a file (.isreg() ) will I try and read it's contents.

I figured a sensible idea would be to pass a socket(.makefile()) object to the 
fileobj attribute of tarfile.open. This doesn't work because a socket file 
descriptor does not have a tell() method. I understand that a socket object 
shouldn't need to have a tell method, but why should the fileobj passed to 
tarfile.open need it?

Code:-

def get_headers( self, file_name ):
sock = socket.socket()
sock.bind(('localhost',0))
fd = sock.makefile()
handle = tarfile.open( file_name,'r',fileobj=fd ) # This line breaks

I'm currently testing on Python v2.6.6 EPD 6.3-2 64 bit, on an Autumn 2010 Mac 
Pro.

My dirty bug-fix idea is to subclass tarfile.TarFile, and give it a tell() 
method, to just return 0. I don't want to have to do that. Any alternative 
suggestions would be greatly appreciated.

Cheers,
Alex

--
components: Extension Modules
messages: 130482
nosy: Alex.Leach
priority: normal
severity: normal
status: open
title: tarfile with socket incompatability

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11458
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11458] tarfile with socket incompatability

2011-03-09 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I believe you are looking for mode 'r|'.

--
nosy: +r.david.murray
resolution:  - works for me
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11458
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com