From 00b062d9eb44a82ff0a3760a96a9fcef99c42b22 Mon Sep 17 00:00:00 2001 From: tuanaiseo Date: Sun, 5 Apr 2026 06:35:23 +0700 Subject: [PATCH] refactor: fragile version parsing can crash with unclear err `get_version()` assumes the regex always matches and calls `.group(1)` directly. If `__version__` format changes or file contents differ, setup fails with an unhelpful `AttributeError`. Affected files: setup.py Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com> --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c8e3f00532..06b8cabd5f 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,10 @@ def get_version(): init = open(os.path.join(ROOT, 'boto3', '__init__.py')).read() - return VERSION_RE.search(init).group(1) + match = VERSION_RE.search(init) + if match is None: + raise RuntimeError('Unable to find __version__ in boto3/__init__.py') + return match.group(1) setup(