##// END OF EJS Templates
remove some cast_unicode
M Bussonnier -
Show More
@@ -16,7 +16,8 from copy import deepcopy
16 16 from os.path import splitext
17 17 from pathlib import Path, PurePath
18 18
19 from IPython.utils.py3compat import cast_unicode
19 from typing import Optional
20
20 21 from IPython.testing.skipdoctest import skip_doctest
21 22 from . import display_functions
22 23
@@ -518,7 +519,7 class SVG(DisplayObject):
518 519 _read_flags = 'rb'
519 520 # wrap data in a property, which extracts the <svg> tag, discarding
520 521 # document headers
521 _data = None
522 _data: Optional[str] = None
522 523
523 524 @property
524 525 def data(self):
@@ -540,7 +541,9 class SVG(DisplayObject):
540 541 # fallback on the input, trust the user
541 542 # but this is probably an error.
542 543 pass
543 svg = cast_unicode(svg)
544 if isinstance(svg, bytes):
545 self._data = svg.decode(errors="replace")
546 else:
544 547 self._data = svg
545 548
546 549 def _repr_svg_(self):
@@ -18,7 +18,6 from IPython.utils.process import find_cmd, FindCmdError
18 18 from traitlets.config import get_config
19 19 from traitlets.config.configurable import SingletonConfigurable
20 20 from traitlets import List, Bool, Unicode
21 from IPython.utils.py3compat import cast_unicode
22 21
23 22
24 23 class LaTeXTool(SingletonConfigurable):
@@ -58,8 +57,9 class LaTeXTool(SingletonConfigurable):
58 57 ).tag(config=True)
59 58
60 59
61 def latex_to_png(s, encode=False, backend=None, wrap=False, color='Black',
62 scale=1.0):
60 def latex_to_png(
61 s: str, encode=False, backend=None, wrap=False, color="Black", scale=1.0
62 ):
63 63 """Render a LaTeX string to PNG.
64 64
65 65 Parameters
@@ -80,7 +80,7 def latex_to_png(s, encode=False, backend=None, wrap=False, color='Black',
80 80 None is returned when the backend cannot be used.
81 81
82 82 """
83 s = cast_unicode(s)
83 assert isinstance(s, str)
84 84 allowed_backends = LaTeXTool.instance().backends
85 85 if backend is None:
86 86 backend = allowed_backends[0]
@@ -170,7 +170,7 try:
170 170 # not really a cl-arg, fallback on _process_common
171 171 return py_arg_split(commandline, posix=posix, strict=strict)
172 172 argvn = c_int()
173 result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn))
173 result_pointer = CommandLineToArgvW(commandline.lstrip(), ctypes.byref(argvn))
174 174 result_array_type = LPCWSTR * argvn.value
175 175 result = [arg for arg in result_array_type.from_address(ctypes.addressof(result_pointer.contents))]
176 176 retval = LocalFree(result_pointer)
General Comments 0
You need to be logged in to leave comments. Login now