Skip to content

Commit

Permalink
Handle all exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet committed Jul 28, 2022
1 parent f46472d commit 31c9a21
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions geoalchemy2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,19 @@ def load_spatialite(dbapi_conn, connection_record):
# back to pkg_resources for Python 3.7 support
try:
import importlib.metadata
__version__ = importlib.metadata.version('GeoAlchemy2')
except ImportError:
try:
from pkg_resources import DistributionNotFound
from pkg_resources import get_distribution
__version__ = get_distribution('GeoAlchemy2').version
except (DistributionNotFound, ImportError): # pragma: no cover
pass # pragma: no cover
except ImportError: # pragma: no cover
pass
else:
try:
__version__ = get_distribution('GeoAlchemy2').version
except DistributionNotFound: # pragma: no cover
pass
else:
try:
__version__ = importlib.metadata.version('GeoAlchemy2')
except importlib.metadata.PackageNotFoundError: # pragma: no cover
pass

0 comments on commit 31c9a21

Please sign in to comment.