Browse Source

Fix some python3 issues

- (str, unicode) instead of six.string_types
- binary/text conversion on None
feature/docs
Andrei 8 years ago
parent
commit
c7a017713a
  1. 2
      disco/bot/bot.py
  2. 6
      disco/types/base.py

2
disco/bot/bot.py

@ -141,7 +141,7 @@ class Bot(LoggingClass):
self.client.events.on('MessageUpdate', self.on_message_update)
# If we have a level getter and its a string, try to load it
if isinstance(self.config.commands_level_getter, (str, unicode)):
if isinstance(self.config.commands_level_getter, six.string_types):
mod, func = self.config.commands_level_getter.rsplit('.', 1)
mod = importlib.import_module(mod)
self.config.commands_level_getter = getattr(mod, func)

6
disco/types/base.py

@ -207,6 +207,9 @@ def datetime(data):
def text(obj):
if obj is None:
return None
if six.PY2:
if isinstance(obj, str):
return obj.decode('utf-8')
@ -216,6 +219,9 @@ def text(obj):
def binary(obj):
if obj is None:
return None
if six.PY2:
if isinstance(obj, str):
return obj.decode('utf-8')

Loading…
Cancel
Save