Force ASCII-only prompt when using PyPy
This commit is contained in:
parent
682a9ab504
commit
27291b5e0e
|
@ -152,4 +152,7 @@ class from :py:class:`pdb.Pdb` and decorate it with
|
||||||
|
|
||||||
just like you used ``python -m pdb``.
|
just like you used ``python -m pdb``.
|
||||||
|
|
||||||
.. warning: PyPy is not supported, PyPy3 is.
|
.. warning:
|
||||||
|
Using PyPy (not PyPy3) forces ASCII-only prompts. In other cases unicode
|
||||||
|
characters are allowed, even if you use `pdbpp
|
||||||
|
<https://pypi.python.org/pypi/pdbpp>`_.
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import platform
|
||||||
|
|
||||||
from powerline import Powerline
|
from powerline import Powerline
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,3 +20,6 @@ class PDBPowerline(Powerline):
|
||||||
def do_setup(self, pdb):
|
def do_setup(self, pdb):
|
||||||
self.update_renderer()
|
self.update_renderer()
|
||||||
self.renderer.set_pdb(pdb)
|
self.renderer.set_pdb(pdb)
|
||||||
|
|
||||||
|
if sys.version_info < (3,) and platform.python_implementation() == 'PyPy':
|
||||||
|
get_encoding = staticmethod(lambda: 'ascii')
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import platform
|
||||||
|
|
||||||
from powerline.renderers.shell.readline import ReadlineRenderer
|
from powerline.renderers.shell.readline import ReadlineRenderer
|
||||||
from powerline.renderer import Renderer
|
from powerline.renderer import Renderer
|
||||||
|
|
||||||
|
@ -35,5 +38,13 @@ class PDBRenderer(ReadlineRenderer):
|
||||||
self.initial_stack_length = len(self.pdb.stack) - 1
|
self.initial_stack_length = len(self.pdb.stack) - 1
|
||||||
return Renderer.render(self, **kwargs)
|
return Renderer.render(self, **kwargs)
|
||||||
|
|
||||||
|
if sys.version_info < (3,) and platform.python_implementation() == 'PyPy':
|
||||||
|
def do_render(self, **kwargs):
|
||||||
|
# Make sure that only ASCII characters survive
|
||||||
|
ret = super(PDBRenderer, self).do_render(**kwargs)
|
||||||
|
ret = ret.encode('ascii', 'replace')
|
||||||
|
ret = ret.decode('ascii')
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
renderer = PDBRenderer
|
renderer = PDBRenderer
|
||||||
|
|
Loading…
Reference in New Issue