From 846e1de5c9564ad827bf94c8307ac830c5200084 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 29 Jul 2020 17:05:58 +0100 Subject: [PATCH 1/3] fix debug.format case from more_debug.py example --- devtools/debug.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/devtools/debug.py b/devtools/debug.py index 480f070..5ad271d 100644 --- a/devtools/debug.py +++ b/devtools/debug.py @@ -311,11 +311,10 @@ def _statement_range(call_frame: 'FrameType', func_name: str) -> 'Tuple[int, int for instr in instructions: # pragma: no branch if instr.starts_line: - if instr.opname in {'LOAD_GLOBAL', 'LOAD_NAME'} and instr.argval == func_name: + if instr.opname in {'LOAD_GLOBAL', 'LOAD_NAME'} and ( + instr.argval == func_name or (instr.argval == 'debug' and next(instructions).argval == func_name) + ): first_line = instr.starts_line - elif instr.opname == 'LOAD_GLOBAL' and instr.argval == 'debug': - if next(instructions).argval == func_name: - first_line = instr.starts_line if instr.offset == call_frame.f_lasti: break From a4474b4fb198d7f0688dccb7eff7eb54575344fa Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 29 Jul 2020 17:08:37 +0100 Subject: [PATCH 2/3] more cleanup --- devtools/debug.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/devtools/debug.py b/devtools/debug.py index 5ad271d..4155b3a 100644 --- a/devtools/debug.py +++ b/devtools/debug.py @@ -310,11 +310,12 @@ def _statement_range(call_frame: 'FrameType', func_name: str) -> 'Tuple[int, int last_line = None for instr in instructions: # pragma: no branch - if instr.starts_line: - if instr.opname in {'LOAD_GLOBAL', 'LOAD_NAME'} and ( - instr.argval == func_name or (instr.argval == 'debug' and next(instructions).argval == func_name) - ): - first_line = instr.starts_line + if ( + instr.starts_line + and instr.opname in {'LOAD_GLOBAL', 'LOAD_NAME'} + and (instr.argval == func_name or (instr.argval == 'debug' and next(instructions).argval == func_name)) + ): + first_line = instr.starts_line if instr.offset == call_frame.f_lasti: break From 1b9e85e17664abdf61584f93ff21666bd0520f90 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 29 Jul 2020 18:02:54 +0100 Subject: [PATCH 3/3] fix badges in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 600112e..68bfbff 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![CI](https://github.com/samuelcolvin/python-devtools/workflows/CI/badge.svg?event=push)](https://github.com/samuelcolvin/python-devtools/actions?query=event%3Apush+branch%3Amaster+workflow%3ACI) [![Coverage](https://codecov.io/gh/samuelcolvin/python-devtools/branch/master/graph/badge.svg)](https://codecov.io/gh/samuelcolvin/python-devtools) -[![pypi](https://img.shields.io/pypi/v/python-devtools.svg)](https://pypi.python.org/pypi/python-devtools) -[![versions](https://img.shields.io/pypi/pyversions/python-devtools.svg)](https://github.com/samuelcolvin/python-devtools) +[![pypi](https://img.shields.io/pypi/v/devtools.svg)](https://pypi.python.org/pypi/python-devtools) +[![versions](https://img.shields.io/pypi/pyversions/devtools.svg)](https://github.com/samuelcolvin/python-devtools) [![license](https://img.shields.io/github/license/samuelcolvin/python-devtools.svg)](https://github.com/samuelcolvin/python-devtools/blob/master/LICENSE) **Python's missing debug print command and other development tools.**