diff --git a/sopel/modules/tell.py b/sopel/modules/tell.py index 2a2717511a..0272ffc2fc 100644 --- a/sopel/modules/tell.py +++ b/sopel/modules/tell.py @@ -13,6 +13,7 @@ import io # don't use `codecs` for loading the DB; it will split lines on some IRC formatting import logging import os +import sys import threading import time import unicodedata @@ -22,6 +23,10 @@ from sopel.tools.time import format_time, get_timezone +if sys.version_info.major >= 3: + unicode = str + + LOGGER = logging.getLogger(__name__) @@ -141,7 +146,7 @@ def _format_safe_lstrip(text): Stolen and tweaked from the ``choose`` plugin's ``_format_safe()`` function by the person who wrote it. """ - if not isinstance(text, str): + if not isinstance(text, unicode): raise TypeError("A string is required.") elif not text: # unnecessary optimization diff --git a/test/modules/test_modules_tell.py b/test/modules/test_modules_tell.py index 9c4d6de3c7..976675da70 100644 --- a/test/modules/test_modules_tell.py +++ b/test/modules/test_modules_tell.py @@ -5,6 +5,7 @@ import datetime import io import os +import sys import pytest @@ -12,6 +13,10 @@ from sopel.modules import tell +if sys.version_info.major >= 3: + unicode = str + + def test_load_reminders_empty(tmpdir): tmpfile = tmpdir.join('tell.db') tmpfile.write('\n')