Problems with "Tarfile.close()"

Dr Rainer Woitok rainer.woitok at gmail.com
Fri Dec 20 12:20:11 EST 2019


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 way also  worked with Python  2, it would be even
better ... :-)

> There are a couple solutions to the Python 3 aspect of the problem here:
> 
>    https://stackoverflow.com/q/908331/208880

Using "sys.stdout.buffer"  seems to work  in Python 3  (at least with my
current rather trivial test case) but does not work in Python 2.  Quest-
ion: what is the cheapest way  to retrieve the Python version the script
is executing in?

Sincerely,
  Rainer


More information about the Python-list mailing list