Address @mvanderkamp's comments in the pylint/drop-py2 PR
This commit is contained in:
parent
2d38c1bef5
commit
71ffa51a29
@ -27,15 +27,7 @@ to start pudb.
|
||||
Insert one of these snippets into the piece of code you want to debug, or
|
||||
run the entire script with::
|
||||
|
||||
pudb my-script.py
|
||||
|
||||
or, in Python 3::
|
||||
|
||||
pudb3 my-script.py
|
||||
|
||||
This is equivalent to::
|
||||
|
||||
python -m pudb.run my-script.py
|
||||
python -m pudb my-script.py
|
||||
|
||||
which is useful if you want to run PuDB in a version of Python other than the
|
||||
one you most recently installed PuDB with.
|
||||
@ -100,11 +92,11 @@ By using the ```stty``` with "no echo: and "no buffering" input options, we
|
||||
can make a socket that nonetheless behave simillarly::
|
||||
|
||||
stty -echo -icanon && nc -l -p 6899
|
||||
|
||||
|
||||
When using the BSD version netcat that ships with MacOS, a server can be started like this::
|
||||
|
||||
stty -echo -icanon && nc -l 6899
|
||||
|
||||
|
||||
Specify host and port in set_trace and set the *reverse* parameter to *True*::
|
||||
|
||||
from pudb.remote import set_trace
|
||||
@ -126,7 +118,7 @@ when debugging with standard pudb. E.g. consider this ``script.py``::
|
||||
# breakpoint was introduced in Python 3.7
|
||||
breakpoint()
|
||||
print('hello', name)
|
||||
|
||||
|
||||
p = Process(target=f, args=('bob',))
|
||||
p.start()
|
||||
p.join()
|
||||
|
@ -58,14 +58,7 @@ def run_with_timeout(code, time, globals=None):
|
||||
"""
|
||||
# Set the signal handler and a ``time``-second alarm
|
||||
signal.signal(signal.SIGALRM, lambda s, f: timeout(s, f, time))
|
||||
if sys.version_info > (2, 5):
|
||||
signal.setitimer(signal.ITIMER_REAL, time)
|
||||
else:
|
||||
# The above only exists in Python 2.6+
|
||||
# Otherwise, we have to use this, which only supports integer arguments
|
||||
# Use math.ceil to round a float up.
|
||||
time = int(math.ceil(time))
|
||||
signal.alarm(time)
|
||||
signal.setitimer(signal.ITIMER_REAL, time)
|
||||
r = eval(code, globals)
|
||||
signal.alarm(0) # Disable the alarm
|
||||
return r
|
||||
|
@ -69,21 +69,8 @@ def _tty_override():
|
||||
def _open_tty(tty_path):
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
if sys.version_info[0] == 2:
|
||||
import fcntl
|
||||
import termios
|
||||
import struct
|
||||
tty_file = open(tty_path, "r+b", buffering=0)
|
||||
try:
|
||||
s = struct.unpack("hh", fcntl.ioctl(
|
||||
tty_file.fileno(), termios.TIOCGWINSZ, "1234"))
|
||||
term_size = (s[1], s[0])
|
||||
except Exception:
|
||||
term_size = None
|
||||
else:
|
||||
tty_file = io.TextIOWrapper(open(tty_path, "r+b", buffering=0))
|
||||
term_size = os.get_terminal_size(tty_file.fileno())
|
||||
tty_file = io.TextIOWrapper(open(tty_path, "r+b", buffering=0))
|
||||
term_size = os.get_terminal_size(tty_file.fileno())
|
||||
|
||||
return tty_file, term_size
|
||||
|
||||
|
@ -501,14 +501,9 @@ class Debugger(bdb.Bdb):
|
||||
|
||||
def _runmodule(self, module_name):
|
||||
# This is basically stolen from the pdb._runmodule from CPython 3.8
|
||||
# and adapted to work also in Python 2
|
||||
# https://github.com/python/cpython/blob/a1d3be4623c8ec7069bd34ccdce336be9cdeb644/Lib/pdb.py#L1530
|
||||
import runpy
|
||||
|
||||
# here we unpack the module details manually, so that it works in PY2 as well
|
||||
mod_details = runpy._get_module_details(module_name)
|
||||
mod_spec = mod_details[1]
|
||||
code = mod_details[2]
|
||||
mod_name, mod_spec, code = runpy._get_module_details(module_name)
|
||||
|
||||
self.mainpyfile = self.canonic(code.co_filename)
|
||||
import __main__
|
||||
@ -518,9 +513,6 @@ class Debugger(bdb.Bdb):
|
||||
"__file__": self.mainpyfile,
|
||||
"__spec__": mod_spec,
|
||||
"__builtins__": __builtins__,
|
||||
})
|
||||
|
||||
__main__.__dict__.update({
|
||||
"__package__": mod_spec.parent,
|
||||
"__loader__": mod_spec.loader,
|
||||
})
|
||||
@ -1734,8 +1726,6 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
sys.stdin = None
|
||||
sys.stderr = sys.stdout = StringIO()
|
||||
try:
|
||||
# Don't use cmdline_get_namespace() here in Python 2, as it
|
||||
# breaks things (issue #166).
|
||||
eval(compile(cmd, "<pudb command line>", "single"),
|
||||
cmdline_get_namespace())
|
||||
except Exception:
|
||||
|
@ -104,18 +104,8 @@ class RemoteDebugger(Debugger):
|
||||
raw_sock_file = self._client.makefile("rwb", 0)
|
||||
import codecs
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
sock_file = codecs.StreamRecoder(
|
||||
raw_sock_file,
|
||||
codecs.getencoder("utf-8"),
|
||||
codecs.getdecoder("utf-8"),
|
||||
codecs.getreader("utf-8"),
|
||||
codecs.getwriter("utf-8"),
|
||||
)
|
||||
else:
|
||||
sock_file = codecs.StreamReaderWriter(
|
||||
raw_sock_file, codecs.getreader("utf-8"), codecs.getwriter("utf-8")
|
||||
)
|
||||
sock_file = codecs.StreamReaderWriter(
|
||||
raw_sock_file, codecs.getreader("utf-8"), codecs.getwriter("utf-8"))
|
||||
|
||||
self._handle = sys.stdin = sys.stdout = sock_file
|
||||
|
||||
|
11
setup.py
11
setup.py
@ -5,12 +5,6 @@ from pudb import VERSION
|
||||
|
||||
import sys
|
||||
|
||||
py_version_major = sys.version_info[0]
|
||||
if py_version_major == 3:
|
||||
PY_VERSION = str(py_version_major)
|
||||
else:
|
||||
PY_VERSION = ""
|
||||
|
||||
try:
|
||||
readme = open("README.rst")
|
||||
long_description = str(readme.read())
|
||||
@ -54,7 +48,10 @@ setup(
|
||||
],
|
||||
packages=["pudb"],
|
||||
entry_points={
|
||||
"console_scripts": ["pudb" + PY_VERSION + " = pudb.run:main"],
|
||||
"console_scripts": [
|
||||
# Deprecated. Should really use python -m pudb.
|
||||
"pudb3 = pudb.run:main",
|
||||
],
|
||||
"gui_script": [],
|
||||
},
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user