Skip to content

Strict detection of tmux version via regex #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def get_version() -> LooseVersion:
)
raise exc.VersionTooLow(proc.stderr)

version = proc.stdout[0].split("tmux ")[1]
version = re.search('[0-9]{1}.[0-9]', proc.stdout[0]).group(0)
Copy link
Member

Choose a reason for hiding this comment

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

What about line 561, wouldn't this lose access to the a in 3.2a?

Copy link
Member

Choose a reason for hiding this comment

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

poetry run mypy .

libtmux/common.py:555: error: Item "None" of "Optional[Match[str]]" has no attribute "group"

This will need null-checks to handle empty matches. I haven't tested, but it'd be something like

Suggested change
version = re.search('[0-9]{1}.[0-9]', proc.stdout[0]).group(0)
match = re.search('[0-9]{1}.[0-9]', proc.stdout[0])
assert match is not None
version = match.group(0)


# Allow latest tmux HEAD
if version == "master":
Expand Down