Bug #6255. Do not use TextIOWrapper when running python2.

svn: r21200
This commit is contained in:
Gary Burton 2013-01-22 20:54:34 +00:00
parent d91be2fd0b
commit c36181d024

View File

@ -371,15 +371,20 @@ class LineParser(object):
try: try:
if use_gzip: if use_gzip:
if sys.version_info[0] == 2:
ofile = gzip.open(filename, "rb")
else:
import io import io
# Bug 6255. TextIOWrapper is required for python3 to present # Bug 6255. TextIOWrapper is required for python3 to
# file contents as text, otherwise they are read # present file contents as text, otherwise they
# as binary. However due to a missing method (read1) # are read as binary. However due to a missing
# in early python3 versions this try block will fail # method (read1) in early python3 versions this
# It should work correctly from version 3.3 # try block will fail.
# Gramps will still import XML files using python # Gramps will still import XML files using python
# versions < 3.3.0 but the file progress meter will # versions < 3.3.0 but the file progress meter
# not work properly, going immediately to 100%. # will not work properly, going immediately to
# 100%.
# It should work correctly from version 3.3.
ofile = io.TextIOWrapper(gzip.open(filename, "rb")) ofile = io.TextIOWrapper(gzip.open(filename, "rb"))
else: else:
ofile = open(filename, "r") ofile = open(filename, "r")