Remove use of fix_long fixer.

This commit is contained in:
Valentin Lorentz 2015-08-08 23:01:02 +02:00
parent be118c3338
commit 5a82cefd51
6 changed files with 17 additions and 7 deletions

View File

@ -38,6 +38,7 @@ import string
import supybot.utils as utils
from supybot.commands import *
import supybot.minisix as minisix
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Math')
@ -94,7 +95,7 @@ class Math(callbacks.Plugin):
def _convertBaseToBase(self, number, toBase, fromBase):
"""Convert a number from any base, 2 through 36, to any other
base, 2 through 36. Returns a string."""
number = long(str(number), fromBase)
number = minisix.long(str(number), fromBase)
if toBase == 10:
return str(number)
return self._convertDecimalToBase(number, toBase)

View File

@ -159,7 +159,6 @@ try:
fixer_names = ['fix_basestring',
'fix_imports',
'fix_long',
'fix_metaclass', 'fix_methodattrs',
'fix_numliterals',
'fix_types',

View File

@ -44,7 +44,8 @@ try:
except ImportError: # Windows!
resource = None
from . import callbacks, conf, ircdb, ircmsgs, ircutils, log, utils, world
from . import callbacks, conf, ircdb, ircmsgs, ircutils, log, minisix, \
utils, world
from .i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization()
@ -272,7 +273,7 @@ def getNonInt(irc, msg, args, state, type=_('non-integer value')):
def getLong(irc, msg, args, state, type='long'):
getInt(irc, msg, args, state, type)
state.args[-1] = long(state.args[-1])
state.args[-1] = minisix.long(state.args[-1])
def getFloat(irc, msg, args, state, type=_('floating point number')):
try:

View File

@ -639,7 +639,7 @@ def dccIP(ip):
def unDccIP(i):
"""Takes an integer DCC IP and return a normal string IP."""
assert isinstance(i, (int, long)), '%r is not an number.' % i
assert isinstance(i, minisix.integer_types), '%r is not an number.' % i
L = []
while len(L) < 4:
L.append(i % 256)

View File

@ -32,9 +32,17 @@
import sys
if sys.version_info[0] >= 3:
PY2 = False
PY3 = True
intern = sys.intern
integer_types = (int,)
long = int
else:
PY2 = True
PY3 = False
if isinstance(__builtins__, dict):
intern = __builtins__['intern']
else:
intern = __builtins__.intern
integer_types = (int, long)
long = long

View File

@ -39,6 +39,7 @@ import time
import string
import textwrap
from .. import minisix
from .iter import all, any
from .structures import TwoWayDictionary
@ -411,7 +412,7 @@ def nItems(n, item, between=None):
>>> nItems(10, 'clock', between='grandfather')
'10 grandfather clocks'
"""
assert isinstance(n, int) or isinstance(n, long), \
assert isinstance(n, minisix.integer_types), \
'The order of the arguments to nItems changed again, sorry.'
if item == '<empty>':
if between is None:
@ -563,7 +564,7 @@ def format(s, *args, **kwargs):
raise ValueError('Invalid value for %%n in format: %s' % t)
elif char == 'S':
t = args.pop()
if not isinstance(t, (int, long)):
if not isinstance(t, minisix.integer_types):
raise ValueError('Invalid value for %%S in format: %s' % t)
for suffix in ['B','KB','MB','GB','TB']:
if t < 1024: