OEIS: Fix compatibility with Python 3.

master
Valentin Lorentz 2013-07-17 14:29:30 +00:00
parent f835498647
commit 84ad48419b
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,7 @@
# Note that you have to follow OEIS' license.
import re
import sys
import logging
class InvalidEntry(Exception):
@ -42,6 +43,8 @@ class OEISEntry(dict):
line = line[0:-1]
if not line:
break
if sys.version_info[0] >= 3 and isinstance(line, bytes):
line = line.decode()
if line.startswith('#'):
continue
try:
@ -95,6 +98,8 @@ class OEISEntry(dict):
paging = None
for line in fd:
line = line[0:-1]
if sys.version_info[0] >= 3 and isinstance(line, bytes):
line = line.decode()
if line.startswith('No results.'):
return ((0, 0, 0), [])
if line.startswith('Showing '):