Incompatiblity with Python 2.6

Bug #1028589 reported by Arfrever Frehtes Taifersar Arahesis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-distutils-extra
New
Undecided
Unassigned

Bug Description

python-distutils-extra >=2.34 uses sys.version_info.major, which does not work with Python 2.6. sys.version_info works as a named tuple since Python 2.7. bytes.decode() and str.encode() accept keyword argument also only Python 2.7.

--- DistUtilsExtra/auto.py
+++ DistUtilsExtra/auto.py
@@ -104,11 +104,11 @@
         enc = locale.getpreferredencoding()
         for f in sorted(src):
             # ensure that we can always print the file name
- if(sys.version_info.major < 3):
+ if(sys.version_info[0] < 3):
                 # hack to make this work with Python 2
- f_loc = f.decode('ascii', errors='ignore')
+ f_loc = f.decode('ascii', 'ignore')
             else:
- f_loc = f.encode(enc, errors='replace').decode(enc, errors='replace')
+ f_loc = f.encode(enc, 'replace').decode(enc, 'replace')
             print (' ' + f_loc)

 #
@@ -387,7 +387,7 @@
         with open(file, 'rb') as f:
             # send binary blob for python2, otherwise sending an unicode object with
             # "encoding" directive makes ast triggering an exception in python2
- if(sys.version_info.major < 3):
+ if(sys.version_info[0] < 3):
                 file_content = f.read()
             else:
                 file_content = f.read().decode('UTF-8')

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.