Skip to content

Commit f414c3f

Browse files
authored
azdev statistics list-command-table: Handle exceptions when source code cannot be retrieved (#421)
* handle exception * update changelog * fix lint
1 parent d4e9490 commit f414c3f

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
33
Release History
44
===============
5+
6+
0.1.60
7+
++++++
8+
* `azdev statistics list-command-table`: Handle exceptions when source code cannot be retrieved
9+
510
0.1.59
611
++++++
712
* `azdev command-change meta-export`: Normalize basic cmd types: str, bool, int, float

azdev/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# -----------------------------------------------------------------------------
66

7-
__VERSION__ = '0.1.59'
7+
__VERSION__ = '0.1.60'

azdev/operations/statistics/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,13 @@ def _get_module_functions(path):
336336

337337

338338
def _expand_all_functions(func, func_map):
339-
source = textwrap.dedent(inspect.getsource(func))
339+
source = ""
340+
try:
341+
source = textwrap.dedent(inspect.getsource(func))
342+
except (OSError, TypeError):
343+
# https://docs.python.org/3/library/inspect.html#inspect.getsource
344+
logger.warning("Cannot retrieve the source code of %s.", func)
345+
340346
if func_map is None:
341347
return source
342348

0 commit comments

Comments
 (0)