Skip to content

compat python 3.13#68

Merged
Jintao-Huang merged 1 commit into
modelscope:mainfrom
Jintao-Huang:compat_py313
May 8, 2026
Merged

compat python 3.13#68
Jintao-Huang merged 1 commit into
modelscope:mainfrom
Jintao-Huang:compat_py313

Conversation

@Jintao-Huang
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates setup.py to use a regular expression for extracting the package version instead of executing the version file. Feedback indicates that the current regex implementation could lead to an AttributeError if no match is found and contains a potentially incorrect character set for quotes; a more robust implementation with error handling was suggested.

Comment thread setup.py
with open(version_file, 'r', encoding='utf-8') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__']
return re.search(r'^__version__\s*=\s*["\'](.+?)["\']', f.read(), re.M).group(1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation has two potential issues:

  1. It will raise an AttributeError if re.search returns None (i.e., the version string is not found), which will crash the setup process.
  2. The regex character set ["\'] is likely incorrect. It matches a double quote, a backslash, or a single quote. The intention is likely to match only a double or single quote, which would be ["'].

A more robust implementation would handle the None case and use the correct regex.

Suggested change
return re.search(r'^__version__\s*=\s*["\'](.+?)["\']', f.read(), re.M).group(1)
match = re.search(r"""^__version__\s*=\s*["'](.+?)["']""", f.read(), re.M)
if not match:
raise RuntimeError('Unable to find version string.')
return match.group(1)

@Jintao-Huang Jintao-Huang merged commit f17e6c4 into modelscope:main May 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant