diff --git a/PkgInfo/plugin.py b/PkgInfo/plugin.py index 75454e4..0129a03 100644 --- a/PkgInfo/plugin.py +++ b/PkgInfo/plugin.py @@ -34,16 +34,15 @@ import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks from collections import OrderedDict, defaultdict -try: - from urllib.parse import urlencode -except ImportError: - from urllib import urlencode +try: # Python 3 + from urllib.parse import urlencode + from html.parser import HTMLParser +except ImportError: # Python 2 + from urllib import urlencode + from HTMLParser import HTMLParser import json import re -try: - from HTMLParser import HTMLParser -except ImportError: - from html.parser import HTMLParser + try: from supybot.i18n import PluginInternationalization _ = PluginInternationalization('PkgInfo') diff --git a/RelayLink/plugin.py b/RelayLink/plugin.py index 4c32a2f..370db55 100644 --- a/RelayLink/plugin.py +++ b/RelayLink/plugin.py @@ -303,7 +303,11 @@ class RelayLink(callbacks.Plugin): args['oldnick'] = '\x03%s%s\x03' % (self.simpleHash(msg.nick), args['oldnick']) args['newnick'] = '\x03%s%s\x03' % (self.simpleHash(msg.args[0]), args['newnick']) s = '%(network)s%(oldnick)s is now known as %(newnick)s' - for (channel, c) in irc.state.channels.iteritems(): + try: + chandict = irc.state.channels.iteritems() + except AttributeError: # Python 3 compatibility + chandict = irc.state.channels.items() + for (channel, c) in chandict: if msg.args[0] in c.users: self.sendToOthers(irc, channel, s, args) diff --git a/TLDInfo/plugin.py b/TLDInfo/plugin.py index 171377b..2e39eae 100644 --- a/TLDInfo/plugin.py +++ b/TLDInfo/plugin.py @@ -53,7 +53,10 @@ class TLDInfo(callbacks.Plugin): db = "http://www.iana.org/domains/root/db/" text = text.split(".")[-1] # IANA's DB doesn't care about second level domains # Encode everything in IDN in order to support international TLDs - s = text.decode("utf8").encode("idna") + try: # Python 2 + s = text.decode("utf8").encode("idna") + except AttributeError: # Python 3 + s = text.encode("idna").decode() try: data = utils.web.getUrl(db + s) except utils.web.Error as e: