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