From cadf953e868ac8f84ad8c9daf5235b26ecfbe289 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 30 Jan 2013 20:10:48 +0100 Subject: [PATCH 01/17] Make the setup.py runnable by Python 3 and run 2to3 automatically. Conflicts: sandbox/run_2to3.sh setup.py --- 2to3/run.py | 30 +++++++++++++++++++++++-- sandbox/run_2to3.sh | 5 ----- setup.py | 55 +++++++++++++++++++++++++-------------------- 3 files changed, 59 insertions(+), 31 deletions(-) mode change 100644 => 100755 2to3/run.py delete mode 100755 sandbox/run_2to3.sh diff --git a/2to3/run.py b/2to3/run.py old mode 100644 new mode 100755 index 4457f5603..90ed51daa --- a/2to3/run.py +++ b/2to3/run.py @@ -1,6 +1,32 @@ -#! /usr/bin/python2.7 +#!/usr/bin/env python +import os import sys -from lib2to3.main import main +import shutil +from glob import glob +try: + from lib2to3.main import main +except ImportError: + print('Error: you need the 2to3 tool to run this script.') +os.chdir(os.path.join(os.path.dirname(__file__), '..')) +try: + os.unlink('src/version.py') +except OSError: + pass +try: + shutil.rmtree('py3k') +except OSError: + pass +os.mkdir('py3k') +for dirname in ('locales', 'docs', 'plugins'): + shutil.copytree(dirname, os.path.join('py3k', dirname)) + +files = ['run.py', 'src', 'plugins', 'test', 'setup.py'] + glob('scripts/*') +args = ['-wWno', 'py3k'] +fixers = [] +for fix in ['all', 'def_iteritems', 'def_itervalues', 'def_iterkeys', 'reload']: + fixers += ['-f', fix] +sys.argv = files + args + fixers + sys.argv +sys.argc = len(sys.argv) import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys, fix_reload diff --git a/sandbox/run_2to3.sh b/sandbox/run_2to3.sh deleted file mode 100755 index 004836a01..000000000 --- a/sandbox/run_2to3.sh +++ /dev/null @@ -1,5 +0,0 @@ -rm -f src/version.py # Prevent 2to3 from copying it, since py3k/src/version.py was probably written by root. -cp locale/ py3k/ -R -cp docs/ py3k/ -R -cp plugins/ py3k/ -R # copy plugins data -python 2to3/run.py src/ plugins/ test/ scripts/* setup.py -wWno py3k -f all -f def_iteritems -f def_itervalues -f def_iterkeys -f reload "$@" diff --git a/setup.py b/setup.py index 7948014f9..61bd4e76b 100644 --- a/setup.py +++ b/setup.py @@ -31,27 +31,8 @@ ### import sys - -if sys.version_info < (2, 6, 0): - sys.stderr.write("Supybot requires Python 2.6 or newer.\n") - sys.exit(-1) - -import textwrap - -clean = False -while '--clean' in sys.argv: - clean = True - sys.argv.remove('--clean') - -import glob -import shutil -import os import subprocess - -plugins = [s for s in os.listdir('plugins') if - os.path.exists(os.path.join('plugins', s, 'plugin.py'))] - version = None try: proc = subprocess.Popen('git show HEAD --format=%ci', shell=True, @@ -60,7 +41,6 @@ try: .strip() \ .replace(' +', '+') \ .replace(' ', 'T') - except: pass if not version: @@ -75,13 +55,40 @@ open(os.path.join('src', 'version.py'), 'a').write( from src.version import version +if sys.version_info < (2, 6, 0): + sys.stderr.write("Supybot requires Python 2.6 or newer.") + sys.stderr.write(os.linesep) + sys.exit(-1) +elif sys.version_info[0] >= 3 and \ + not os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1] == 'py3k': + # The second condition is used to prevent this script to run recursively + subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')]).wait() + os.chdir('py3k') + subprocess.Popen([sys.executable] + sys.argv).wait() + + +import textwrap + +clean = False +while '--clean' in sys.argv: + clean = True + sys.argv.remove('--clean') + +import glob +import shutil +import os + + +plugins = [s for s in os.listdir('plugins') if + os.path.exists(os.path.join('plugins', s, 'plugin.py'))] + def normalizeWhitespace(s): return ' '.join(s.split()) try: from distutils.core import setup from distutils.sysconfig import get_python_lib -except ImportError, e: +except ImportError as e: s = normalizeWhitespace("""Supybot requires the distutils package to install. This package is normally included with Python, but for some unfathomable reason, many distributions to take it out of standard Python @@ -102,10 +109,10 @@ if clean: previousInstall = os.path.join(get_python_lib(), 'supybot') if os.path.exists(previousInstall): try: - print 'Removing current installation.' + print('Removing current installation.') shutil.rmtree(previousInstall) - except Exception, e: - print 'Couldn\'t remove former installation: %s' % e + except Exception as e: + print('Couldn\'t remove former installation: %s' % e) sys.exit(-1) packages = ['supybot', From 170183adbd94368253439a05b72e58fff48a6a3e Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 30 Jan 2013 20:38:31 +0100 Subject: [PATCH 02/17] setup.py: exit after it has called itself. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 61bd4e76b..e31eb1b17 100644 --- a/setup.py +++ b/setup.py @@ -65,6 +65,7 @@ elif sys.version_info[0] >= 3 and \ subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')]).wait() os.chdir('py3k') subprocess.Popen([sys.executable] + sys.argv).wait() + exit() import textwrap From 4a032834fb2476988f50f80fd915317e2cd052b8 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 2 Feb 2013 19:56:54 +0100 Subject: [PATCH 03/17] setup.py: Fix bug if setup is not in the current working directory. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index e31eb1b17..fb042d6f2 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,8 @@ import sys import subprocess +os.chdir(os.path.dirname(__file__)) + version = None try: proc = subprocess.Popen('git show HEAD --format=%ci', shell=True, From c7a1779f53998524f96ddfe5a9838549b81300b7 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 2 Feb 2013 19:59:03 +0100 Subject: [PATCH 04/17] Fix previous commit --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fb042d6f2..8bdcfa8fd 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,9 @@ import sys import subprocess -os.chdir(os.path.dirname(__file__)) +path = os.path.dirname(__file__) +if path: + os.chdir(path) version = None try: From 29421f3cd75e7abc20db4c26756e32f1d0e2e456 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 2 Feb 2013 20:47:31 +0100 Subject: [PATCH 05/17] setup.py: Hide 2to3's output. --- setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8bdcfa8fd..efa8d05bb 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ ### import sys +import tempfile import subprocess path = os.path.dirname(__file__) @@ -66,7 +67,13 @@ if sys.version_info < (2, 6, 0): elif sys.version_info[0] >= 3 and \ not os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1] == 'py3k': # The second condition is used to prevent this script to run recursively - subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')]).wait() + print('Converting code from Python 2 to Python 3. This make take a ' + 'few minutes.') + # For some reason, using open(os.devnull) makes the subprocess exit before + # it finishes... + subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')], + stdout=tempfile.TemporaryFile(), + stderr=tempfile.TemporaryFile()).wait() os.chdir('py3k') subprocess.Popen([sys.executable] + sys.argv).wait() exit() From 3e26a2d7cf7b7e8a0d592a3a73a53b1a42987d66 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 22 Feb 2013 20:50:38 +0100 Subject: [PATCH 06/17] setup.py: Add the --debug switch. --- setup.py | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index efa8d05bb..2f6accac9 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,11 @@ import sys import tempfile import subprocess +debug = '--debug' in sys.argv + path = os.path.dirname(__file__) +if debug: + print('DEBUG: Changing dir from %r to %r' % (os.getcwd(), path)) if path: os.chdir(path) @@ -64,19 +68,32 @@ if sys.version_info < (2, 6, 0): sys.stderr.write("Supybot requires Python 2.6 or newer.") sys.stderr.write(os.linesep) sys.exit(-1) -elif sys.version_info[0] >= 3 and \ - not os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1] == 'py3k': - # The second condition is used to prevent this script to run recursively - print('Converting code from Python 2 to Python 3. This make take a ' - 'few minutes.') - # For some reason, using open(os.devnull) makes the subprocess exit before - # it finishes... - subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')], - stdout=tempfile.TemporaryFile(), - stderr=tempfile.TemporaryFile()).wait() - os.chdir('py3k') - subprocess.Popen([sys.executable] + sys.argv).wait() - exit() +elif sys.version_info[0] >= 3: + if os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1] == 'py3k': + if debug: + print('DEBUG: Running setup.py with Python 3: second stage.') + while '--debug' in sys.argv: + sys.argv.remove('--debug') + else: + if debug: + print('DEBUG: Running setup.py with Python 3: first stage.') + print('Converting code from Python 2 to Python 3. This make take a ' + 'few minutes.') + # For some reason, using open(os.devnull) makes the subprocess exit before + # it finishes... + subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')], + stdout=tempfile.TemporaryFile(), + stderr=tempfile.TemporaryFile()).wait() + if debug: + print('DEBUG: Changing dir to py3k/') + os.chdir('py3k') + if debug: + print('DEBUG: Running %r' % ([sys.executable] + sys.argv)) + subprocess.Popen([sys.executable] + sys.argv).wait() + exit() +else: + while '--debug' in sys.argv: + sys.argv.remove('--debug') import textwrap From 38d039ada28f5ffd984a7daac75417696e007989 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 22 Feb 2013 21:17:16 +0100 Subject: [PATCH 07/17] setup.py: In debug mode, display 2to3 logs. --- setup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 2f6accac9..16d7901ad 100644 --- a/setup.py +++ b/setup.py @@ -81,9 +81,13 @@ elif sys.version_info[0] >= 3: 'few minutes.') # For some reason, using open(os.devnull) makes the subprocess exit before # it finishes... - subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')], - stdout=tempfile.TemporaryFile(), - stderr=tempfile.TemporaryFile()).wait() + if debug: + subprocess.Popen([sys.executable, + os.path.join('2to3', 'run.py')]).wait() + else: + subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')], + stdout=tempfile.TemporaryFile(), + stderr=tempfile.TemporaryFile()).wait() if debug: print('DEBUG: Changing dir to py3k/') os.chdir('py3k') From 20665cf31d8c0ba80e2e3abf1d3b1f43b6871a70 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 22 Feb 2013 21:17:55 +0100 Subject: [PATCH 08/17] 2to3/run.py: Fix compatibility issue with old Python 3.x versions (2to3 does not suport -W and -o). --- 2to3/run.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/2to3/run.py b/2to3/run.py index 90ed51daa..522b0f6bf 100755 --- a/2to3/run.py +++ b/2to3/run.py @@ -17,11 +17,14 @@ try: except OSError: pass os.mkdir('py3k') -for dirname in ('locales', 'docs', 'plugins'): +for dirname in ('locales', 'docs', 'plugins', 'src', 'test'): shutil.copytree(dirname, os.path.join('py3k', dirname)) +for filename in ('setup.py',): + shutil.copyfile(filename, os.path.join('py3k', filename)) +os.chdir('py3k') files = ['run.py', 'src', 'plugins', 'test', 'setup.py'] + glob('scripts/*') -args = ['-wWno', 'py3k'] +args = ['-wn'] fixers = [] for fix in ['all', 'def_iteritems', 'def_itervalues', 'def_iterkeys', 'reload']: fixers += ['-f', fix] From 3b44bc34b75c291ddd9027a5ea469000d744bb3d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 22 Feb 2013 20:26:26 +0000 Subject: [PATCH 09/17] Fix previous commit. --- 2to3/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2to3/run.py b/2to3/run.py index 522b0f6bf..5234e2ef7 100755 --- a/2to3/run.py +++ b/2to3/run.py @@ -17,7 +17,7 @@ try: except OSError: pass os.mkdir('py3k') -for dirname in ('locales', 'docs', 'plugins', 'src', 'test'): +for dirname in ('locales', 'docs', 'plugins', 'src', 'test', 'scripts'): shutil.copytree(dirname, os.path.join('py3k', dirname)) for filename in ('setup.py',): shutil.copyfile(filename, os.path.join('py3k', filename)) From 00d9567b4fb4853338c2aa3d90ad0df4377dfcd1 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 25 Mar 2013 16:28:33 +0100 Subject: [PATCH 10/17] Fix typo. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 16d7901ad..e6822eab8 100644 --- a/setup.py +++ b/setup.py @@ -77,7 +77,7 @@ elif sys.version_info[0] >= 3: else: if debug: print('DEBUG: Running setup.py with Python 3: first stage.') - print('Converting code from Python 2 to Python 3. This make take a ' + print('Converting code from Python 2 to Python 3. This may take a ' 'few minutes.') # For some reason, using open(os.devnull) makes the subprocess exit before # it finishes... From c84d3d6b75f250d12e2adf9cfe356dbd3c6734dd Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 27 Apr 2013 16:05:11 +0200 Subject: [PATCH 11/17] Speed up install on Python3 (2to3 is ran only on modified files). --- 2to3/__init__.py | 0 setup.py | 60 ++++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 2to3/__init__.py diff --git a/2to3/__init__.py b/2to3/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/setup.py b/setup.py index e6822eab8..ad5433dd1 100644 --- a/setup.py +++ b/setup.py @@ -68,36 +68,6 @@ if sys.version_info < (2, 6, 0): sys.stderr.write("Supybot requires Python 2.6 or newer.") sys.stderr.write(os.linesep) sys.exit(-1) -elif sys.version_info[0] >= 3: - if os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1] == 'py3k': - if debug: - print('DEBUG: Running setup.py with Python 3: second stage.') - while '--debug' in sys.argv: - sys.argv.remove('--debug') - else: - if debug: - print('DEBUG: Running setup.py with Python 3: first stage.') - print('Converting code from Python 2 to Python 3. This may take a ' - 'few minutes.') - # For some reason, using open(os.devnull) makes the subprocess exit before - # it finishes... - if debug: - subprocess.Popen([sys.executable, - os.path.join('2to3', 'run.py')]).wait() - else: - subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')], - stdout=tempfile.TemporaryFile(), - stderr=tempfile.TemporaryFile()).wait() - if debug: - print('DEBUG: Changing dir to py3k/') - os.chdir('py3k') - if debug: - print('DEBUG: Running %r' % ([sys.executable] + sys.argv)) - subprocess.Popen([sys.executable] + sys.argv).wait() - exit() -else: - while '--debug' in sys.argv: - sys.argv.remove('--debug') import textwrap @@ -137,6 +107,35 @@ except ImportError as e: sys.stderr.write(textwrap.fill(s)) sys.stderr.write(os.linesep*2) sys.exit(-1) +try: + from distutils.command.build_py import build_py_2to3 + class build_py(build_py_2to3): + def run_2to3(self, files, options=None): + from distutils import log + from lib2to3.refactor import RefactoringTool, get_fixers_from_package + if not files: + return + + # Make this class local, to delay import of 2to3 + from lib2to3.refactor import RefactoringTool, get_fixers_from_package + class DistutilsRefactoringTool(RefactoringTool): + def log_error(self, msg, *args, **kw): + log.error(msg, *args) + + def log_message(self, msg, *args): + log.info(msg, *args) + + def log_debug(self, msg, *args): + log.debug(msg, *args) + + fixer_names = get_fixers_from_package('lib2to3.fixes') + fixer_names += get_fixers_from_package('2to3') + r = DistutilsRefactoringTool(fixer_names, options=options) + r.refactor(files, write=True) +except ImportError: + # 2.x + from distutils.command.build_py import build_py + if clean: previousInstall = os.path.join(get_python_lib(), 'supybot') @@ -217,6 +216,7 @@ setup( 'Operating System :: Microsoft :: Windows', 'Programming Language :: Python', ], + cmdclass = {'build_py': build_py}, # Installation data packages=packages, From 0608676d0a2e4807ece7e316e8034a526fcd152f Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 10 May 2013 17:55:31 +0200 Subject: [PATCH 12/17] setup.py: Remove error output if not in a git repo. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ad5433dd1..86a18b33b 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ if path: version = None try: proc = subprocess.Popen('git show HEAD --format=%ci', shell=True, - stdout=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE) version = proc.stdout.readline() \ .strip() \ .replace(' +', '+') \ From f8a57b78e4bfc248f5b9b57e9914e35097be6d2c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 24 Feb 2013 01:51:40 +0100 Subject: [PATCH 13/17] Google: Fix snarfer with Python 3. --- plugins/Google/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 9f42baff0..cd2763c9e 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -244,7 +244,7 @@ class Google(callbacks.PluginRegexp): data = self.search(searchString, msg.args[0], {'smallsearch': True}) if data['responseData']['results']: url = data['responseData']['results'][0]['unescapedUrl'] - irc.reply(url.encode('utf-8'), prefixNick=False) + irc.reply(url, prefixNick=False) googleSnarfer = urlSnarfer(googleSnarfer) def _googleUrl(self, s): From a55611a49e909dd6e8fc6f8b98de639fec1068cc Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 25 Mar 2013 19:15:08 +0100 Subject: [PATCH 14/17] core: Various Python 3 compatibility fixes. Conflicts: src/httpserver.py --- src/commands.py | 3 ++- src/httpserver.py | 4 ++-- src/test.py | 9 ++++++--- src/utils/str.py | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/commands.py b/src/commands.py index 970f1c918..32c428cf1 100644 --- a/src/commands.py +++ b/src/commands.py @@ -870,6 +870,7 @@ class first(context): spec(irc, msg, args, state) return except Exception, e: + e2 = e # 'e' is local. errored = state.errored state.errored = False continue @@ -877,7 +878,7 @@ class first(context): state.args.append(self.default) else: state.errored = errored - raise e + raise e2 class reverse(context): def __call__(self, irc, msg, args, state): diff --git a/src/httpserver.py b/src/httpserver.py index b0bba8a46..0aff3330a 100644 --- a/src/httpserver.py +++ b/src/httpserver.py @@ -138,7 +138,7 @@ class SupyHTTPServerCallback: self.send_header('Content_type', 'text/plain; charset=utf-8') self.send_header('Content-Length', len(self.defaultResponse)) self.end_headers() - self.wfile.write(self.defaultResponse) + self.wfile.write(self.defaultResponse.encode()) doPost = doHead = doGet @@ -159,7 +159,7 @@ class Supy404(SupyHTTPServerCallback): self.send_header('Content_type', 'text/plain; charset=utf-8') self.send_header('Content-Length', len(self.response)) self.end_headers() - self.wfile.write(self.response) + self.wfile.write(self.response.encode()) doPost = doHead = doGet diff --git a/src/test.py b/src/test.py index 7c1594ef4..d0aa11684 100644 --- a/src/test.py +++ b/src/test.py @@ -38,7 +38,6 @@ import urllib import httplib import unittest import threading -import StringIO import supybot.log as log import supybot.i18n as i18n @@ -568,8 +567,12 @@ class HTTPPluginTestCase(PluginTestCase): def request(self, url, method='GET', read=True, data={}): assert url.startswith('/') - wfile = StringIO.StringIO() - rfile = StringIO.StringIO() + try: + from io import BytesIO as StringIO + except ImportError: + from StringIO import StringIO + wfile = StringIO() + rfile = StringIO() connection = FakeHTTPConnection(wfile, rfile) connection.putrequest(method, url) connection.endheaders() diff --git a/src/utils/str.py b/src/utils/str.py index 93cabc008..591517daf 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -455,7 +455,8 @@ def format(s, *args, **kwargs): return has(args.pop()) elif char == 'L': t = args.pop() - if isinstance(t, list): + if isinstance(t, list) or (sys.version_info[0] >= 3 and + (isinstance(t, map) or isinstance(t, filter))): return commaAndify(t) elif isinstance(t, tuple) and len(t) == 2: if not isinstance(t[0], list): From 75c3d2fa89833011e4d31c22304a6d1ada422f5b Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 27 Apr 2013 18:18:38 +0200 Subject: [PATCH 15/17] Dict: Use normal import (was broken in Python 3.3 for some reason). --- plugins/Dict/plugin.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/Dict/plugin.py b/plugins/Dict/plugin.py index ca6bfb526..a1fff5a00 100644 --- a/plugins/Dict/plugin.py +++ b/plugins/Dict/plugin.py @@ -40,12 +40,7 @@ _ = PluginInternationalization('Dict') import random -try: - dictclient = utils.python.universalImport('dictclient', 'local.dictclient') -except ImportError: - raise callbacks.Error, \ - 'You need to have dictclient installed to use this plugin. ' \ - 'Download it at ' +from local import dictclient class Dict(callbacks.Plugin): threaded = True From f0e49a04029dce7b2cf6428d4ccbb2e193c82dea Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 8 May 2013 19:28:16 +0000 Subject: [PATCH 16/17] Math: Fix load on Python 3. --- plugins/Math/plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index 3e648d8ac..2e2b0df86 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -42,7 +42,10 @@ import supybot.callbacks as callbacks from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Math') -convertcore = utils.python.universalImport('local.convertcore') +try: + from local import convertcore +except ImportError: + from .local import convertcore baseArg = ('int', 'base', lambda i: i <= 36) From cd6d9da8e45095eea837a853a153819c01cc954a Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 9 May 2013 10:16:51 +0200 Subject: [PATCH 17/17] Debug: Fix Python 3 compatibility. --- sandbox/Debug/plugin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sandbox/Debug/plugin.py b/sandbox/Debug/plugin.py index 3ee72750f..c5d7f398a 100644 --- a/sandbox/Debug/plugin.py +++ b/sandbox/Debug/plugin.py @@ -40,7 +40,16 @@ import gc import os import pwd import sys -import exceptions +try: + import exceptions +except ImportError: # Python 3 + import builtins + class exceptions: + """Pseudo-module""" + pass + for (key, value) in exceptions.__dict__.items(): + if isinstance(value, type) and issubclass(value, Exception): + exceptions[key] = value import supybot.conf as conf import supybot.utils as utils