From 7f0e1115b5fd2d3dee6ffa1c633a76af86853a22 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 4 Aug 2012 18:06:49 +0200 Subject: [PATCH] Make world.py py3k-friendly. --- src/world.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/world.py b/src/world.py index c69d37a7a..015a2724b 100644 --- a/src/world.py +++ b/src/world.py @@ -113,7 +113,13 @@ def debugFlush(s=''): def upkeep(): """Does upkeep (like flushing, garbage collection, etc.)""" - sys.exc_clear() # Just in case, let's clear the exception info. + # Just in case, let's clear the exception info. + try: + sys.exc_clear() + except AttributeError: + # Python 3 does not have sys.exc_clear. The except statement clears + # the info itself (and we've just entered an except statement) + pass if os.name == 'nt': try: import msvcrt @@ -153,7 +159,8 @@ def upkeep(): #if registryFilename is not None: # registry.open(registryFilename) if not dying: - log.debug('Regexp cache size: %s', len(sre._cache)) + if sys.version_info[0] < 3: + log.debug('Regexp cache size: %s', len(sre._cache)) log.debug('Pattern cache size: %s', len(ircutils._patternCache)) log.debug('HostmaskPatternEqual cache size: %s', len(ircutils._hostmaskPatternEqualCache))