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

View File

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

View File

@ -44,7 +44,8 @@ try:
except ImportError: # Windows! except ImportError: # Windows!
resource = None 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 from .i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization() _ = PluginInternationalization()
@ -272,7 +273,7 @@ def getNonInt(irc, msg, args, state, type=_('non-integer value')):
def getLong(irc, msg, args, state, type='long'): def getLong(irc, msg, args, state, type='long'):
getInt(irc, msg, args, state, type) 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')): def getFloat(irc, msg, args, state, type=_('floating point number')):
try: try:

View File

@ -639,7 +639,7 @@ def dccIP(ip):
def unDccIP(i): def unDccIP(i):
"""Takes an integer DCC IP and return a normal string IP.""" """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 = [] L = []
while len(L) < 4: while len(L) < 4:
L.append(i % 256) L.append(i % 256)

View File

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

View File

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