##// END OF EJS Templates
remove unicode_type function
Srinivas Reddy Thatiparthy -
Show More
@@ -18,7 +18,7 b' import struct'
18 18 import sys
19 19 import warnings
20 20
21 from IPython.utils.py3compat import cast_bytes_py2, cast_unicode, unicode_type
21 from IPython.utils.py3compat import cast_bytes_py2, cast_unicode
22 22 from IPython.testing.skipdoctest import skip_doctest
23 23
24 24 __all__ = ['display', 'display_pretty', 'display_html', 'display_markdown',
@@ -492,7 +492,7 b' class DisplayObject(object):'
492 492
493 493 self.data = data
494 494 self.url = url
495 self.filename = None if filename is None else unicode_type(filename)
495 self.filename = filename
496 496
497 497 self.reload()
498 498 self._check_data()
@@ -876,7 +876,7 b' class Image(DisplayObject):'
876 876 # jpg->jpeg
877 877 format = self._FMT_JPEG
878 878
879 self.format = unicode_type(format).lower()
879 self.format = format.lower()
880 880 self.embed = embed if embed is not None else (url is None)
881 881
882 882 if self.embed and self.format not in self._ACCEPTABLE_EMBEDDINGS:
@@ -953,7 +953,7 b' class Image(DisplayObject):'
953 953 return self._data_and_metadata()
954 954
955 955 def _find_ext(self, s):
956 return unicode_type(s.split('.')[-1].lower())
956 return s.split('.')[-1].lower()
957 957
958 958 class Video(DisplayObject):
959 959
@@ -1037,7 +1037,7 b' class Video(DisplayObject):'
1037 1037 video = f.read()
1038 1038 else:
1039 1039 video = self.data
1040 if isinstance(video, unicode_type):
1040 if isinstance(video, str):
1041 1041 # unicode input is already b64-encoded
1042 1042 b64_video = video
1043 1043 else:
@@ -29,7 +29,7 b' from traitlets import ('
29 29 default, observe,
30 30 )
31 31 from IPython.utils.py3compat import (
32 with_metaclass, unicode_type,
32 with_metaclass
33 33 )
34 34
35 35
@@ -737,7 +737,7 b' class PNGFormatter(BaseFormatter):'
737 737
738 738 print_method = ObjectName('_repr_png_')
739 739
740 _return_type = (bytes, unicode_type)
740 _return_type = (bytes, str)
741 741
742 742
743 743 class JPEGFormatter(BaseFormatter):
@@ -755,7 +755,7 b' class JPEGFormatter(BaseFormatter):'
755 755
756 756 print_method = ObjectName('_repr_jpeg_')
757 757
758 _return_type = (bytes, unicode_type)
758 _return_type = (bytes, str)
759 759
760 760
761 761 class LatexFormatter(BaseFormatter):
@@ -846,7 +846,7 b' class PDFFormatter(BaseFormatter):'
846 846
847 847 print_method = ObjectName('_repr_pdf_')
848 848
849 _return_type = (bytes, unicode_type)
849 _return_type = (bytes, str)
850 850
851 851 class IPythonDisplayFormatter(BaseFormatter):
852 852 """A Formatter for objects that know how to display themselves.
@@ -67,7 +67,7 b' from IPython.utils.ipstruct import Struct'
67 67 from IPython.paths import get_ipython_dir
68 68 from IPython.utils.path import get_home_dir, get_py_filename, ensure_dir_exists
69 69 from IPython.utils.process import system, getoutput
70 from IPython.utils.py3compat import builtin_mod, unicode_type, with_metaclass
70 from IPython.utils.py3compat import builtin_mod, with_metaclass
71 71 from IPython.utils.strdispatch import StrDispatch
72 72 from IPython.utils.syspathcontext import prepended_to_syspath
73 73 from IPython.utils.text import format_screen, LSString, SList, DollarFormatter
@@ -2340,7 +2340,7 b' class InteractiveShell(SingletonConfigurable):'
2340 2340 exc_info = {
2341 2341 u'status' : 'error',
2342 2342 u'traceback' : stb,
2343 u'ename' : unicode_type(etype.__name__),
2343 u'ename' : etype.__name__,
2344 2344 u'evalue' : py3compat.safe_unicode(evalue),
2345 2345 }
2346 2346
@@ -12,7 +12,6 b' from IPython.core.magic import Magics, magics_class, line_magic, magic_escapes'
12 12 from IPython.utils.text import format_screen, dedent, indent
13 13 from IPython.testing.skipdoctest import skip_doctest
14 14 from IPython.utils.ipstruct import Struct
15 from IPython.utils.py3compat import unicode_type
16 15 from warnings import warn
17 16 from logging import error
18 17
@@ -550,7 +549,7 b' Currently the magic system has the following functions:""",'
550 549 help=argparse.SUPPRESS
551 550 )
552 551 @magic_arguments.argument(
553 'filename', type=unicode_type,
552 'filename', type=str,
554 553 help='Notebook name or filename'
555 554 )
556 555 @line_magic
@@ -25,7 +25,6 b' from IPython.testing.skipdoctest import skip_doctest'
25 25 from IPython.utils.encoding import DEFAULT_ENCODING
26 26 from IPython.utils.openpy import read_py_file
27 27 from IPython.utils.path import get_py_filename
28 from IPython.utils.py3compat import unicode_type
29 28
30 29 #-----------------------------------------------------------------------------
31 30 # Magic implementation classes
@@ -460,8 +459,8 b' class NamespaceMagics(Magics):'
460 459 try:
461 460 vstr = str(var)
462 461 except UnicodeEncodeError:
463 vstr = unicode_type(var).encode(DEFAULT_ENCODING,
464 'backslashreplace')
462 vstr = var.encode(DEFAULT_ENCODING,
463 'backslashreplace')
465 464 except:
466 465 vstr = "<object with id %d (str() failed)>" % id(var)
467 466 vstr = vstr.replace('\n', '\\n')
@@ -35,7 +35,6 b' from IPython.testing.skipdoctest import skip_doctest'
35 35 from IPython.utils.openpy import source_to_unicode
36 36 from IPython.utils.process import abbrev_cwd
37 37 from IPython.utils import py3compat
38 from IPython.utils.py3compat import unicode_type
39 38 from IPython.utils.terminal import set_term_title
40 39
41 40 #-----------------------------------------------------------------------------
@@ -764,7 +763,7 b' class OSMagics(Magics):'
764 763 'The file will be created if it does not exist.'
765 764 )
766 765 @magic_arguments.argument(
767 'filename', type=unicode_type,
766 'filename', type=str,
768 767 help='file to write'
769 768 )
770 769 @cell_magic
@@ -20,7 +20,7 b' class LazyEvaluate(object):'
20 20 return str(self())
21 21
22 22 def __unicode__(self):
23 return py3compat.unicode_type(self())
23 return self.__str__()
24 24
25 25 def __format__(self, format_spec):
26 26 return format(self(), format_spec)
@@ -18,7 +18,6 b' from IPython.core import completer'
18 18 from IPython.external.decorators import knownfailureif
19 19 from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory
20 20 from IPython.utils.generics import complete_object
21 from IPython.utils.py3compat import unicode_type
22 21 from IPython.testing import decorators as dec
23 22
24 23 #-----------------------------------------------------------------------------
@@ -102,7 +101,7 b' def test_line_split():'
102 101 check_line_split(sp, t)
103 102 # Ensure splitting works OK with unicode by re-running the tests with
104 103 # all inputs turned into unicode
105 check_line_split(sp, [ map(unicode_type, p) for p in t] )
104 check_line_split(sp, [ map(str, p) for p in t] )
106 105
107 106
108 107 def test_custom_completion_error():
@@ -123,7 +122,7 b' def test_unicode_completions():'
123 122 # Some strings that trigger different types of completion. Check them both
124 123 # in str and unicode forms
125 124 s = ['ru', '%ru', 'cd /', 'floa', 'float(x)/']
126 for t in s + list(map(unicode_type, s)):
125 for t in s + list(map(str, s)):
127 126 # We don't need to check exact completion values (they may change
128 127 # depending on the state of the namespace, but at least no exceptions
129 128 # should be thrown and the return value should be a pair of text, list
@@ -32,7 +32,7 b' from IPython.testing.decorators import ('
32 32 from IPython.testing import tools as tt
33 33 from IPython.utils.process import find_cmd
34 34 from IPython.utils import py3compat
35 from IPython.utils.py3compat import unicode_type, PY3
35 from IPython.utils.py3compat import PY3
36 36
37 37 if PY3:
38 38 from io import StringIO
@@ -473,7 +473,7 b' class InteractiveShellTestCase(unittest.TestCase):'
473 473 def test_inspect_text(self):
474 474 ip.run_cell('a = 5')
475 475 text = ip.object_inspect_text('a')
476 self.assertIsInstance(text, unicode_type)
476 self.assertIsInstance(text, str)
477 477
478 478
479 479 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
@@ -5,7 +5,6 b' import unittest'
5 5
6 6 from IPython.core.prompts import LazyEvaluate
7 7 from IPython.testing.globalipapp import get_ipython
8 from IPython.utils.py3compat import unicode_type
9 8
10 9 ip = get_ipython()
11 10
@@ -14,8 +13,7 b' class PromptTests(unittest.TestCase):'
14 13 def test_lazy_eval_unicode(self):
15 14 u = u'ünicødé'
16 15 lz = LazyEvaluate(lambda : u)
17 # str(lz) would fail
18 self.assertEqual(unicode_type(lz), u)
16 self.assertEqual(str(lz), u)
19 17 self.assertEqual(format(lz), u)
20 18
21 19 def test_lazy_eval_nonascii_bytes(self):
@@ -31,7 +29,6 b' class PromptTests(unittest.TestCase):'
31 29 lz = LazyEvaluate(lambda : f)
32 30
33 31 self.assertEqual(str(lz), str(f))
34 self.assertEqual(unicode_type(lz), unicode_type(f))
35 32 self.assertEqual(format(lz), str(f))
36 33 self.assertEqual(format(lz, '.1'), '0.5')
37 34
@@ -3,7 +3,6 b' import nose.tools as nt'
3 3 from IPython.core.error import TryNext
4 4 from IPython.lib.clipboard import ClipboardEmpty
5 5 from IPython.testing.decorators import skip_if_no_x11
6 from IPython.utils.py3compat import unicode_type
7 6
8 7 @skip_if_no_x11
9 8 def test_clipboard_get():
@@ -19,4 +18,4 b' def test_clipboard_get():'
19 18 # No clipboard access API available
20 19 pass
21 20 else:
22 nt.assert_is_instance(a, unicode_type)
21 nt.assert_is_instance(a, str)
@@ -10,7 +10,6 b' from io import TextIOWrapper, BytesIO'
10 10 import os.path
11 11 import re
12 12
13 from .py3compat import unicode_type
14 13
15 14 cookie_re = re.compile(r"coding[:=]\s*([-\w.]+)", re.UNICODE)
16 15 cookie_comment_re = re.compile(r"^\s*#.*coding[:=]\s*([-\w.]+)", re.UNICODE)
@@ -129,7 +128,7 b" def source_to_unicode(txt, errors='replace', skip_encoding_cookie=True):"
129 128 txt can be either a bytes buffer or a string containing the source
130 129 code.
131 130 """
132 if isinstance(txt, unicode_type):
131 if isinstance(txt, str):
133 132 return txt
134 133 if isinstance(txt, bytes):
135 134 buffer = BytesIO(txt)
@@ -25,8 +25,7 b' else:'
25 25 filename = py3compat.cast_bytes(filename, sys.getfilesystemencoding())
26 26 lines = linecache.getlines(filename, module_globals=module_globals)
27 27
28 # The bits we cache ourselves can be unicode.
29 if (not lines) or isinstance(lines[0], py3compat.unicode_type):
28 if (not lines) or isinstance(lines[0], str):
30 29 return lines
31 30
32 31 readline = openpy._list_readline(lines)
General Comments 0
You need to be logged in to leave comments. Login now