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 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

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