diff options
author | kalenz <nh@kalenz.fr> | 2015-02-03 08:45:22 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2015-02-09 19:18:37 +0100 |
commit | f3741058de44ec373e4d3d1001a66176081f1797 (patch) | |
tree | b63b28b74135acb56d2c5f012a2f84ebc204535a | |
parent | bfe6f3de40ea391f66bf69f592f77704e54cb766 (diff) | |
download | miniircd-f3741058de44ec373e4d3d1001a66176081f1797.tar.gz miniircd-f3741058de44ec373e4d3d1001a66176081f1797.zip |
Python 3 support
-rwxr-xr-x | miniircd | 17 | ||||
-rw-r--r-- | test.py | 4 |
2 files changed, 10 insertions, 11 deletions
@@ -541,7 +541,7 @@ class Client(object): self.server.print_debug( "[%s:%d] -> %r" % (self.host, self.port, data)) quitmsg = "EOT" - except socket.error, x: + except socket.error as x: data = "" quitmsg = x if data: @@ -559,7 +559,7 @@ class Client(object): "[%s:%d] <- %r" % ( self.host, self.port, self.__writebuffer[:sent])) self.__writebuffer = self.__writebuffer[sent:] - except socket.error, x: + except socket.error as x: self.disconnect(x) def disconnect(self, quitmsg): @@ -705,12 +705,12 @@ class Server(object): def print_info(self, msg): if self.verbose: - print msg + print(msg) sys.stdout.flush() def print_debug(self, msg): if self.debug: - print msg + print(msg) sys.stdout.flush() def print_error(self, msg): @@ -800,11 +800,10 @@ class Server(object): client.check_aliveness() last_aliveness_check = now - -_alpha = "abcdefghijklmnopqrstuvwxyz" -_ircstring_translation = string.maketrans( - string.upper(_alpha) + "[]\\^", - _alpha + "{}|~") +_maketrans = str.maketrans if sys.version_info[0] == 3 else string.maketrans +_ircstring_translation = _maketrans( + string.ascii_lowercase.upper() + "[]\\^", + string.ascii_lowercase + "{}|~") def irc_lower(s): @@ -1,4 +1,4 @@ -#!/usr/bin/python +#! /usr/bin/env python import os import re @@ -44,7 +44,7 @@ class ServerFixture(object): except socket.error: tries_left -= 1 time.sleep(0.01) - self.connections[nick] = s.makefile() + self.connections[nick] = s.makefile(mode="rw") self.send(nick, "NICK %s" % nick) self.send(nick, "USER %s * * %s" % (nick, nick)) self.expect(nick, r":local\S+ 001 %s :.*" % nick) |