Skip to content

Commit

Permalink
Merge pull request #3237 from charris/2to3-apply-basestring
Browse files Browse the repository at this point in the history
2to3: Apply basestring fixer.
  • Loading branch information
charris committed Apr 14, 2013
2 parents e589c6e + 68338ee commit 01ed88a
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 16 deletions.
5 changes: 4 additions & 1 deletion numpy/compat/py3k.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@

__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar',
'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested',
'asstr', 'open_latin1', 'long']
'asstr', 'open_latin1', 'long', 'basestring']

import sys

if sys.version_info[0] >= 3:
import io

long = int
integer_types = (int,)
basestring = str
bytes = bytes
unicode = str

Expand Down Expand Up @@ -45,6 +47,7 @@ def open_latin1(filename, mode='r'):
bytes = str
unicode = unicode
long = long
basestring = basestring
integer_types = (int, long)
asbytes = str
asstr = str
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/memmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import numpy as np
from .numeric import uint8, ndarray, dtype
from numpy.compat import long
from numpy.compat import long, basestring

dtypedescr = dtype
valid_filemodes = ["r", "c", "r+", "w+"]
Expand Down
3 changes: 2 additions & 1 deletion numpy/core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import sys
import warnings
import collections
from . import multiarray
from . import umath
from .umath import *
from . import numerictypes
from .numerictypes import *
import collections

if sys.version_info[0] >= 3:
import pickle
basestring = str
else:
import cPickle as pickle

Expand Down
9 changes: 6 additions & 3 deletions numpy/distutils/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
"""
from __future__ import division, absolute_import, print_function

__revision__ = "$Id: extension.py,v 1.1 2005/04/09 19:29:34 pearu Exp $"

import sys
import re
from distutils.extension import Extension as old_Extension

import re
if sys.version_info[0] >= 3:
basestring = str


cxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\Z',re.I).match
fortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\Z',re.I).match

Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/_iotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import sys
import numpy as np
import numpy.core.numeric as nx
from numpy.compat import asbytes, bytes, asbytes_nested, long, basestring

if sys.version_info[0] >= 3:
from builtins import bool, int, float, complex, object, unicode, str
else:
from __builtin__ import bool, int, float, complex, object, unicode, str

from numpy.compat import asbytes, bytes, asbytes_nested, long

if sys.version_info[0] >= 3:
def _bytes_to_complex(s):
Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
import numpy
import sys
from numpy.lib.utils import safe_eval
from numpy.compat import asbytes, isfileobj, long
from numpy.compat import asbytes, isfileobj, long, basestring

if sys.version_info[0] >= 3:
import pickle
Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
_is_string_like, has_nested_fields, flatten_dtype, \
easy_dtype, _bytes_to_name

from numpy.compat import asbytes, asstr, asbytes_nested, bytes
from numpy.compat import asbytes, asstr, asbytes_nested, bytes, basestring
from io import BytesIO

if sys.version_info[0] >= 3:
Expand Down
1 change: 1 addition & 0 deletions numpy/lib/recfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from numpy.ma import MaskedArray
from numpy.ma.mrecords import MaskedRecords
from numpy.lib._iotools import _is_string_like
from numpy.compat import basestring

if sys.version_info[0] >= 3:
izip = zip
Expand Down
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from numpy import ndarray, amax, amin, iscomplexobj, bool_
from numpy import array as narray
from numpy.lib.function_base import angle
from numpy.compat import getargspec, formatargspec, long
from numpy.compat import getargspec, formatargspec, long, basestring
from numpy import expand_dims as n_expand_dims

if sys.version_info[0] >= 3:
Expand Down
13 changes: 8 additions & 5 deletions numpy/ma/mrecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
__author__ = "Pierre GF Gerard-Marchant"

import sys
import warnings

import numpy as np
from numpy import bool_, dtype, \
ndarray, recarray, array as narray
import numpy.core.numerictypes as ntypes
from numpy.core.records import fromarrays as recfromarrays, \
fromrecords as recfromrecords
from numpy.compat import basestring
from numpy import (
bool_, dtype, ndarray, recarray, array as narray
)
from numpy.core.records import (
fromarrays as recfromarrays, fromrecords as recfromrecords
)

_byteorderconv = np.core.records._byteorderconv
_typestr = ntypes._typestr
Expand All @@ -37,7 +41,6 @@

_check_fill_value = ma.core._check_fill_value

import warnings

__all__ = ['MaskedRecords', 'mrecarray',
'fromarrays', 'fromrecords', 'fromtextfile', 'addfield',
Expand Down
1 change: 1 addition & 0 deletions numpy/testing/nosetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import warnings
import numpy.testing.utils
from numpy.compat import basestring

def get_package_name(filepath):
"""
Expand Down
2 changes: 1 addition & 1 deletion tools/py3tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# available fixers, with fixers not currently skipped commented out.
FIXES_TO_SKIP = [
'apply',
# 'basestring',
'basestring',
'buffer',
'callable',
'dict',
Expand Down

0 comments on commit 01ed88a

Please sign in to comment.