Unverified Commit 57ff8d4a authored by teor's avatar teor
Browse files

practracker: Read unicode files when using Python 2

Allow the "practracker" coding best practices checking script to read
unicode files, when using Python 2.

We made the script use unicode literals in 0.4.3.1-alpha, but didn't
change the codec for opening files.

Fixes bug 33374; bugfix on 0.4.3.1-alpha.
parent a79841fd
o Minor bugfixes (coding best practices checks):
- Allow the "practracker" coding best practices checking script to read
unicode files, when using Python 2. We made the script use unicode
literals in 0.4.3.1-alpha, but didn't change the codec for opening files.
Fixes bug 33374; bugfix on 0.4.3.1-alpha.
......@@ -24,7 +24,7 @@ from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os, sys
import codecs, os, sys
import metrics
import util
......@@ -63,12 +63,8 @@ TOR_TOPDIR = None
#######################################################
if sys.version_info[0] <= 2:
def open_file(fname):
return open(fname, 'r')
else:
def open_file(fname):
return open(fname, 'r', encoding='utf-8')
def open_file(fname):
return codecs.open(fname, 'r', encoding='utf-8')
def consider_file_size(fname, f):
"""Consider the size of 'f' and yield an FileSizeItem for it.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment