pyminifier icon indicating copy to clipboard operation
pyminifier copied to clipboard

Opening a file with an encoding keyword argument in Python 2.7

Open pelegm opened this issue 8 years ago • 2 comments

The line

f = open(options.outfile, 'w', encoding='utf-8')

does not work in Python 2.7. I think this is a result of this commit: de35cbb39f28f6903220f8c7568b95907c64ee40

pelegm avatar Feb 03 '17 10:02 pelegm

I have same issue here.

tsaiian avatar Apr 07 '17 12:04 tsaiian

The solution to work properly under Python 3 and Python 2.7 is change the open function which gets used to the open function of the builtin "io" module: from io import open

wagnerpeer avatar Apr 21 '17 09:04 wagnerpeer