Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

setup.py: fix version parsing on Python 3.14 (ast.Str removed)#589

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sookach wants to merge1 commit intohtml5lib:master
base:master
Choose a base branch
Loading
fromsookach:pr/gh-588

Conversation

sookach
Copy link

@sookachsookach commentedSep 13, 2025
edited
Loading

Python 3.14 removes the ast.Str node type. String literals now appear as ast.Constant(value=str).
Update the AST check to accept both ast.Str (for older Pythons) and ast.Constant with a string value (for Python 3.8+), allowing html5lib to build successfully on Python 3.14 while remaining compatible with older version. Tested at desk withpip install -e .

Fixes:#588

Python 3.14 removes the ast.Str node type. String literals now appearas ast.Constant(value=str).Update the AST check to accept both ast.Str (for older Pythons) andast.Constant with a string value (for Python 3.8+), allowing html5lib tobuild successfully on Python 3.14 while remaining compatible with olderversion.
@atsampson
Copy link

This isn't right for pre-3.14 versions - theversion = line fails because there's noa.value.value on older versions. Something like this works (tested on 2.7 and 3.11-3.14):

version = Nonewith open(join(here, "html5lib", "__init__.py"), "rb") as init_file:    t = ast.parse(init_file.read(), filename="__init__.py", mode="exec")    assert isinstance(t, ast.Module)    assignments = filter(lambda x: isinstance(x, ast.Assign), t.body)    for a in assignments:        if (len(a.targets) == 1 and                isinstance(a.targets[0], ast.Name) and                a.targets[0].id == "__version__"):            if hasattr(ast, "Str") and isinstance(a.value, ast.Str):                version = a.value.s            elif (hasattr(ast, "Constant")                  and isinstance(a.value, ast.Constant)                  and isinstance(a.value.value, str)):                version = a.value.valueassert version is not None
sookach reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

html5lib fails to build on Python 3.14 (uses removed ast.Str node)
2 participants
@sookach@atsampson

[8]ページ先頭

©2009-2025 Movatter.jp