liftoff / pyminifier

Pyminifier is a Python code minifier, obfuscator, and compressor.
GNU General Public License v3.0
1.45k stars 223 forks source link

Opening a file with an encoding keyword argument in Python 2.7 #83

Open pelegm opened 7 years ago

pelegm commented 7 years ago

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

tsaiian commented 7 years ago

I have same issue here.

wagnerpeer commented 7 years ago

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