Browse Source

raise RuntimeError instead of Exception when libc's dlinfo function fails (fixes pylint's broad-exception-raised warning)

Fabian Peter Hammerle 1 year ago
parent
commit
71c2bfd732
2 changed files with 5 additions and 2 deletions
  1. 4 1
      CHANGELOG.md
  2. 1 1
      dlinfo/_glibc.py

+ 4 - 1
CHANGELOG.md

@@ -6,8 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
 and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
 and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
 
 
 ## [Unreleased]
 ## [Unreleased]
+### Changed
+- Raise `RuntimeError` instead of `Exception` when libc's `dlinfo` function fails.
+
 ### Removed
 ### Removed
-- compatibility with `python3.5` & `python3.6` (reached end-of-life)
+- Compatibility with `python3.5` & `python3.6` (reached end-of-life)
 
 
 ## [1.2.1] - 2021-04-21 
 ## [1.2.1] - 2021-04-21 
 ### Fixed
 ### Fixed

+ 1 - 1
dlinfo/_glibc.py

@@ -36,7 +36,7 @@ class DLInfo:  # pylint: disable=too-few-public-methods
         _linkmap = ctypes.c_void_p()
         _linkmap = ctypes.c_void_p()
         # pylint: disable=protected-access
         # pylint: disable=protected-access
         if _DLINFO(cdll._handle, _RTLD_DI_LINKMAP, ctypes.byref(_linkmap)) != 0:  # pragma: no cover
         if _DLINFO(cdll._handle, _RTLD_DI_LINKMAP, ctypes.byref(_linkmap)) != 0:  # pragma: no cover
-            raise Exception(f"dlinfo on {cdll._name} failed")
+            raise RuntimeError(f"dlinfo on {cdll._name} failed")
         self._linkmap = ctypes.cast(_linkmap, ctypes.POINTER(_LinkMap))
         self._linkmap = ctypes.cast(_linkmap, ctypes.POINTER(_LinkMap))
 
 
     @property
     @property