Skip to content
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

Do not use deprecated Ellipsis and Str #73

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

Expand All @@ -37,7 +37,7 @@ jobs:

build_generic_wheel:
name: Build generic wheel (without speedups)
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
env:
# Build a wheel without speedups that can run on pure Python
GENSHI_BUILD_SPEEDUP: 0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11-dev", pypy2, pypy3]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", pypy2, pypy3]

steps:
- uses: actions/checkout@v2
Expand Down
17 changes: 10 additions & 7 deletions genshi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
except ImportError:
import _ast as ast
import sys
import warnings
from types import CodeType

import six
Expand Down Expand Up @@ -137,13 +138,15 @@ def build_code_chunk(code, filename, name, lineno):

# In Python 3.8, Str and Ellipsis was replaced by Constant

try:
_ast_Ellipsis = ast.Ellipsis
_ast_Str = ast.Str
_ast_Str_value = lambda obj: obj.s
except AttributeError:
_ast_Ellipsis = _ast_Str = ast.Constant
_ast_Str_value = lambda obj: obj.value
with warnings.catch_warnings():
warnings.filterwarnings('error', category=DeprecationWarning)
try:
_ast_Ellipsis = ast.Ellipsis
_ast_Str = ast.Str
_ast_Str_value = lambda obj: obj.s
except (AttributeError, DeprecationWarning):
_ast_Ellipsis = _ast_Str = ast.Constant
_ast_Str_value = lambda obj: obj.value

class _DummyASTItem(object):
pass
Expand Down
Loading