Re: Problems with "Tarfile.close()"

2019-12-21 Thread Barry
> On 20 Dec 2019, at 15:31, Dr Rainer Woitok wrote: > > Greetings, > > One of my Python scripts basically does the following: > > source = tarfile.open(name=tar_archive , mode='r|*') > dest = tarfile.open(fileobj=sys.stdout, mode='w|', format=fmt) > > . > . > . > > source.close() >

Re: Problems with "Tarfile.close()"

2019-12-21 Thread Dr Rainer Woitok
Chris, On Saturday, 2019-12-21 06:45:24 +1100, you wrote: > ... > This construct can be simplified down to: > > stdout = getattr(sys.stdout, "buffer", sys.stdout) Nice! And with my admittedly trivial test case it correctly works under both, Python 2 and Python 3. Now I'll do some more

Re: Problems with "Tarfile.close()"

2019-12-20 Thread Chris Angelico
On Sat, Dec 21, 2019 at 6:13 AM Peter Otten <__pete...@web.de> wrote: > > Dr Rainer Woitok wrote: > > > Ethan, > > > > On Friday, 2019-12-20 07:41:51 -0800, you wrote: > > > >> ... > >> In Python 3 `sys.stdout` is a character interface, not bytes. > > > > Does that mean that with Python 3

Re: Problems with "Tarfile.close()"

2019-12-20 Thread Peter Otten
Dr Rainer Woitok wrote: > Ethan, > > On Friday, 2019-12-20 07:41:51 -0800, you wrote: > >> ... >> In Python 3 `sys.stdout` is a character interface, not bytes. > > Does that mean that with Python 3 "Tarfile" is no longer able to write > the "tar" file to a pipe? Or is there now another

Re: Problems with "Tarfile.close()"

2019-12-20 Thread Dr Rainer Woitok
Ethan, On Friday, 2019-12-20 07:41:51 -0800, you wrote: > ... > In Python 3 `sys.stdout` is a character interface, not bytes. Does that mean that with Python 3 "Tarfile" is no longer able to write the "tar" file to a pipe? Or is there now another way to write to a pipe? And if that new

Re: Problems with "Tarfile.close()"

2019-12-20 Thread Ethan Furman
On 12/20/2019 04:19 AM, Dr Rainer Woitok wrote: One of my Python scripts basically does the following: source = tarfile.open(name=tar_archive , mode='r|*') dest = tarfile.open(fileobj=sys.stdout, mode='w|', format=fmt) . . . source.close() dest.close() In an attempt to move my

Re: Problems with "Tarfile.close()"

2019-12-20 Thread Chris Angelico
On Sat, Dec 21, 2019 at 2:29 AM Dr Rainer Woitok wrote: > > Greetings, > > One of my Python scripts basically does the following: > > source = tarfile.open(name=tar_archive , mode='r|*') > dest = tarfile.open(fileobj=sys.stdout, mode='w|', format=fmt) > > . > . > . > > source.close() >

Problems with "Tarfile.close()"

2019-12-20 Thread Dr Rainer Woitok
Greetings, One of my Python scripts basically does the following: source = tarfile.open(name=tar_archive , mode='r|*') dest = tarfile.open(fileobj=sys.stdout, mode='w|', format=fmt) . . . source.close() dest.close() In an attempt to move my Python scripts from Python 2.7 to Python 3.6