UtilitiesPython2/pep8.py

changeset 1145
2a16484e65c2
parent 945
8cd4d08fa9f6
child 1509
c0b5e693b0eb
equal deleted inserted replaced
1144:6185688709ff 1145:2a16484e65c2
254 line = physical_line.rstrip() 254 line = physical_line.rstrip()
255 length = len(line) 255 length = len(line)
256 if length > MAX_LINE_LENGTH: 256 if length > MAX_LINE_LENGTH:
257 try: 257 try:
258 # The line could contain multi-byte characters 258 # The line could contain multi-byte characters
259 if not hasattr(line, 'decode'): # Python 3 259 if hasattr(line, 'decode'): # Python 2 only
260 line = line.encode('latin-1') 260 length = len(line.decode('utf-8'))
261 length = len(line.decode('utf-8'))
262 except UnicodeDecodeError: 261 except UnicodeDecodeError:
263 pass 262 pass
264 if length > MAX_LINE_LENGTH: 263 if length > MAX_LINE_LENGTH:
265 return MAX_LINE_LENGTH, "E501", length 264 return MAX_LINE_LENGTH, "E501", length
266 265

eric ide

mercurial