Commit b8ffb0f04605e6c11c3d452e42ce15d303e48f68
1 parent
6917ff21
Delete entry in __init__.py only if it exists
Showing
1 changed file
with
5 additions
and
4 deletions
pyext/ctools/__init__.py.in
| 1 | # ========================================================================== | 1 | # ========================================================================== |
| 2 | # ctools Python module | 2 | # ctools Python module |
| 3 | # | 3 | # |
| 4 | -# Copyright (C) 2015-2016 Juergen Knoedlseder | 4 | +# Copyright (C) 2015-2021 Juergen Knoedlseder |
| 5 | # | 5 | # |
| 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
| @@ -26,14 +26,15 @@ from @PYTHON_RELATIVE_IMPORT@tools import * | @@ -26,14 +26,15 @@ from @PYTHON_RELATIVE_IMPORT@tools import * | ||
| 26 | # Remove swig register stuff | 26 | # Remove swig register stuff |
| 27 | bad_entries = [entry for entry in list(locals()) | 27 | bad_entries = [entry for entry in list(locals()) |
| 28 | if entry.endswith('_swigregister')] | 28 | if entry.endswith('_swigregister')] |
| 29 | -for entry in bad_entries: | ||
| 30 | - del locals()[entry] | 29 | +if len(bad_entries) > 0: |
| 30 | + for entry in bad_entries: | ||
| 31 | + del locals()[entry] | ||
| 32 | + del entry | ||
| 31 | 33 | ||
| 32 | # Clean-up | 34 | # Clean-up |
| 33 | del tools | 35 | del tools |
| 34 | del gammalib | 36 | del gammalib |
| 35 | del bad_entries | 37 | del bad_entries |
| 36 | -del entry | ||
| 37 | 38 | ||
| 38 | # Add version | 39 | # Add version |
| 39 | __version__ = '@PACKAGE_VERSION@' | 40 | __version__ = '@PACKAGE_VERSION@' |