Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Placate new Flake8; add some license headers
  • Loading branch information
inducer committed Oct 29, 2017
1 parent 6be804e commit 54fca02
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 32 deletions.
28 changes: 27 additions & 1 deletion pudb/__init__.py
@@ -1,5 +1,31 @@
from __future__ import absolute_import, division, print_function

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


NUM_VERSION = (2017, 1, 4)
VERSION = ".".join(str(nv) for nv in NUM_VERSION)
__version__ = VERSION
Expand Down Expand Up @@ -95,7 +121,7 @@ def runscript(mainpyfile, args=None, pre_run="", steal_output=False):
se = sys.exc_info()[1]
status_msg = "The debuggee exited normally with " \
"status code %s.\n\n" % se.code
except:
except Exception:
dbg.post_mortem = True
dbg.interaction(None, sys.exc_info())

Expand Down
27 changes: 26 additions & 1 deletion pudb/__main__.py
@@ -1,6 +1,31 @@

from __future__ import absolute_import, division, print_function

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


if __name__ == "__main__":
from pudb.run import main
main()
39 changes: 33 additions & 6 deletions pudb/debugger.py
Expand Up @@ -2,6 +2,33 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


import urwid
import bdb
import gc
Expand Down Expand Up @@ -572,7 +599,7 @@ def get_lines(self, debugger_ui):
lines = getlines(self.file_name)
return format_source(
debugger_ui, list(decode_lines(lines)), set(breakpoints))
except:
except Exception:
from pudb.lowlevel import format_exception
debugger_ui.message("Could not load source file '%s':\n\n%s" % (
self.file_name, "".join(format_exception(sys.exc_info()))),
Expand Down Expand Up @@ -1346,7 +1373,7 @@ def keypress(self, size, key):
new_mod_name = filt_edit.get_edit_text()
try:
__import__(str(new_mod_name))
except:
except Exception:
from pudb.lowlevel import format_exception

self.message("Could not import module '%s':\n\n%s" % (
Expand Down Expand Up @@ -1541,7 +1568,7 @@ def cmdline_exec(w, size, key):
eval(compile(cmd, "<pudb command line>", 'single'),
self.debugger.curframe.f_globals,
self.debugger.curframe.f_locals)
except:
except Exception:
tp, val, tb = sys.exc_info()

import traceback
Expand Down Expand Up @@ -1779,7 +1806,7 @@ def run_external_cmdline(w, size, key):
from os.path import expanduser
execfile(
expanduser(CONFIG["shell"]), shell.custom_shell_dict)
except:
except Exception:
print("Error when importing custom shell:")
from traceback import print_exc
print_exc()
Expand Down Expand Up @@ -1885,7 +1912,7 @@ def help(w, size, key):
if curses:
try:
curses.setupterm()
except:
except Exception:
# Something went wrong--oh well. Nobody will die if their
# 256 color support breaks. Just carry on without it.
# https://github.com/inducer/pudb/issues/78
Expand Down Expand Up @@ -2404,7 +2431,7 @@ def make_frame_ui(frame_lineno):
if code.co_argcount and code.co_varnames[0] == "self":
try:
class_name = frame.f_locals["self"].__class__.__name__
except:
except Exception:
pass

return StackFrame(frame is self.debugger.curframe,
Expand Down
39 changes: 33 additions & 6 deletions pudb/lowlevel.py
@@ -1,20 +1,47 @@
from __future__ import absolute_import, division, print_function

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


from pudb.py3compat import PY3


# {{{ breakpoint validity

def generate_executable_lines_for_code(code):
l = code.co_firstlineno
yield l
lineno = code.co_firstlineno
yield lineno
if PY3:
for c in code.co_lnotab[1::2]:
l += c
yield l
lineno += c
yield lineno
else:
for c in code.co_lnotab[1::2]:
l += ord(c)
yield l
lineno += ord(c)
yield lineno


def get_executable_lines_for_file(filename):
Expand Down
28 changes: 27 additions & 1 deletion pudb/remote.py
Expand Up @@ -2,6 +2,32 @@

from __future__ import absolute_import, print_function, unicode_literals

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


# mostly stolen from celery.contrib.rdb


Expand Down Expand Up @@ -162,7 +188,7 @@ def set_trace(frame=None, term_size=None, host=PUDB_RDB_HOST, port=PUDB_RDB_PORT
# Getting terminal size
s = struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ, '1234'))
term_size = (s[1], s[0])
except:
except Exception:
term_size = (80, 24)

return debugger(term_size=term_size, host=host, port=port).set_trace(frame)
32 changes: 29 additions & 3 deletions pudb/settings.py
@@ -1,5 +1,31 @@
from __future__ import absolute_import, division, print_function

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


import os
import sys

Expand Down Expand Up @@ -58,7 +84,7 @@ def load_config():

if cparser.has_section(CONF_SECTION):
conf_dict.update(dict(cparser.items(CONF_SECTION)))
except:
except Exception:
pass

conf_dict.setdefault("shell", "internal")
Expand Down Expand Up @@ -91,7 +117,7 @@ def normalize_bool_inplace(name):
conf_dict[name] = False
else:
conf_dict[name] = True
except:
except Exception:
pass

normalize_bool_inplace("line_numbers")
Expand All @@ -117,7 +143,7 @@ def save_config(conf_dict):
outf = open(join(save_path, CONF_FILE_NAME), "w")
cparser.write(outf)
outf.close()
except:
except Exception:
pass


Expand Down
32 changes: 29 additions & 3 deletions pudb/source_view.py
@@ -1,5 +1,31 @@
from __future__ import absolute_import, division, print_function

__copyright__ = """
Copyright (C) 2009-2017 Andreas Kloeckner
Copyright (C) 2014-2017 Aaron Meurer
"""

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


import urwid


Expand Down Expand Up @@ -101,11 +127,11 @@ def render(self, size, focus=False):
# means: gobble up remainder of text and rest of line
# and fill with attribute

l = hscroll+maxcol
rowlen = hscroll+maxcol
remaining_text = text[i:]
encoded_seg_text, seg_cs = apply_target_encoding(
remaining_text + l*" ")
encoded_attr.append((seg_attr, len(remaining_text)+l))
remaining_text + rowlen*" ")
encoded_attr.append((seg_attr, len(remaining_text)+rowlen))
else:
unencoded_seg_text = text[i:i+seg_len]
encoded_seg_text, seg_cs = apply_target_encoding(unencoded_seg_text)
Expand Down

0 comments on commit 54fca02

Please sign in to comment.