From 84ad48419b896eb359df24bb9e0c61357c727347 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 17 Jul 2013 14:29:30 +0000 Subject: [PATCH] OEIS: Fix compatibility with Python 3. --- OEIS/oeis.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OEIS/oeis.py b/OEIS/oeis.py index 43285bf..78d536c 100644 --- a/OEIS/oeis.py +++ b/OEIS/oeis.py @@ -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 '):