[New-bugs-announce] [issue9235] missing "import sys" in Tools/gdb/libpython.py

Yaroslav Halchenko report at bugs.python.org
Mon Jul 12 22:40:35 CEST 2010


New submission from Yaroslav Halchenko <yarikoptic at gmail.com>:

as you can see from below, sys. is used, but never imported (besides a docstring)


$> git describe
upstream/0.5.0.dev-875-gf06319e

$> grep -5 'sys' /home/yoh/proj/misc/python/Tools/gdb/libpython.py

"""
During development, I've been manually invoking the code in this way:
(gdb) python

import sys
sys.path.append('/home/david/coding/python-gdb')
import libpython
end

then reloading it after each edit like this:
(gdb) python reload(libpython)
--

    def print_summary(self):
        if self.is_evalframeex():
            pyop = self.get_pyop()
            if pyop:
                sys.stdout.write('#%i %s\n' % (self.get_index(), pyop.get_truncated_repr(MAX_OUTPUT_LEN)))
                sys.stdout.write(pyop.current_line())
            else:
                sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
        else:
            sys.stdout.write('#%i\n' % self.get_index())

class PyList(gdb.Command):
    '''List the current Python source code, if any

    Use
--
            for i, line in enumerate(all_lines[start-1:end]):
                linestr = str(i+start)
                # Highlight current line:
                if i + start == lineno:
                    linestr = '>' + linestr
                sys.stdout.write('%4s    %s' % (linestr, line))


# ...and register the command:
PyList()

----------
components: Demos and Tools
messages: 110134
nosy: Yaroslav.Halchenko
priority: normal
severity: normal
status: open
title: missing "import sys" in Tools/gdb/libpython.py
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9235>
_______________________________________


More information about the New-bugs-announce mailing list