Skip to content

Commit

Permalink
Bump min Python to 3.10 (#392)
Browse files Browse the repository at this point in the history
* Bump min Python to 3.10

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Try to fix fuzzing

* Remove broken docs job

* Revert "Try to fix fuzzing"

This reverts commit d505866.

* Disable fuzzing until it can be fixed for python 3.10

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
  • Loading branch information
3 people committed May 8, 2024
1 parent ec4deb9 commit de0972e
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 106 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,4 @@ jobs:
uses: ./.github/workflows/windows.yml
macos:
uses: ./.github/workflows/macos.yml
docs:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install
run: |
pip install -U pip
pip install git+https://github.com/angr/archinfo.git
pip install .[docs]
- name: Build docs
run: cd docs && make html
- name: Build coverage
run: cd docs && make coverage
- name: Test coverage
run: |
if [ -s docs/_build/coverage/python.txt ]; then
echo "Doc coverage is missing for the for:"
cat docs/_build/coverage/python.txt
exit 1
fi

8 changes: 4 additions & 4 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: OSS-Fuzz

on:
push:
branches:
- master
pull_request:
# push:
# branches:
# - master
# pull_request:
workflow_dispatch:

permissions: {}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
path: binaries
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.10"
- run: python -m venv $HOME/venv
name: Create venv
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
path: binaries
- uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.10"
- run: python -m venv $HOME/venv
name: Create venv
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ repos:
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py310-plus]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ submodules:
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.10"
jobs:
pre_install:
- pip install -U pip
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 120
target-version = ['py38']
target-version = ['py310']
force-exclude = '''
/(
vex
Expand Down
6 changes: 2 additions & 4 deletions pyvex/arches.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict, List, Tuple

from ._register_info import REGISTER_OFFSETS
from .enums import default_vex_archinfo, vex_endness_from_string
from .types import Register
Expand All @@ -17,8 +15,8 @@ def __init__(self, name: str, bits: int, memory_endness: str, instruction_endnes
self.memory_endness = memory_endness
self.instruction_endness = instruction_endness
self.byte_width = 8
self.register_list: List[Register] = []
self.registers: Dict[str, Tuple[int, int]] = {}
self.register_list: list[Register] = []
self.registers: dict[str, tuple[int, int]] = {}
self.vex_arch = {
"X86": "VexArchX86",
"AMD64": "VexArchAMD64",
Expand Down
22 changes: 11 additions & 11 deletions pyvex/block.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import itertools
import logging
from typing import List, Optional, Tuple
from typing import Optional

from . import expr, stmt
from .const import get_type_size
Expand Down Expand Up @@ -125,17 +125,17 @@ def __init__(
self.addr = mem_addr
self.arch: Arch = arch

self.statements: List[IRStmt] = []
self.next: Optional[IRExpr] = None
self.statements: list[IRStmt] = []
self.next: IRExpr | None = None
self._tyenv: Optional["IRTypeEnv"] = None
self.jumpkind: Optional[str] = None
self._direct_next: Optional[bool] = None
self._size: Optional[int] = None
self._instructions: Optional[int] = None
self._exit_statements: Optional[Tuple[Tuple[int, int, IRStmt], ...]] = None
self.jumpkind: str | None = None
self._direct_next: bool | None = None
self._size: int | None = None
self._instructions: int | None = None
self._exit_statements: tuple[tuple[int, int, IRStmt], ...] | None = None
self.default_exit_target = None
self.data_refs = ()
self._instruction_addresses: Tuple[int, ...] = ()
self._instruction_addresses: tuple[int, ...] = ()

if data is not None:
# This is the slower path (because we need to call _from_py() to copy the content in the returned IRSB to
Expand Down Expand Up @@ -180,7 +180,7 @@ def has_statements(self) -> bool:
return self.statements is not None and bool(self.statements)

@property
def exit_statements(self) -> Tuple[Tuple[int, int, IRStmt], ...]:
def exit_statements(self) -> tuple[tuple[int, int, IRStmt], ...]:
if self._exit_statements is not None:
return self._exit_statements

Expand Down Expand Up @@ -409,7 +409,7 @@ def instructions(self):
return self._instructions

@property
def instruction_addresses(self) -> Tuple[int, ...]:
def instruction_addresses(self) -> tuple[int, ...]:
"""
Addresses of instructions in this block.
"""
Expand Down
25 changes: 12 additions & 13 deletions pyvex/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from typing import List, Optional

from .enums import VEXObject, get_enum_from_int
from .errors import PyVEXError
Expand All @@ -11,7 +10,7 @@ class IRConst(VEXObject):
__slots__ = ["_value"]

type: str
size: Optional[int] = None
size: int | None = None
tag: str
c_constructor = None
_value: int
Expand Down Expand Up @@ -58,7 +57,7 @@ def __hash__(self):


class U1(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_I1"
size = 1
Expand All @@ -78,7 +77,7 @@ def _from_c(c_const):


class U8(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_I8"
size = 8
Expand All @@ -101,7 +100,7 @@ def _from_c(c_const):


class U16(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_I16"
size = 16
Expand Down Expand Up @@ -129,7 +128,7 @@ def _from_c(c_const):


class U32(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_I32"
size = 32
Expand Down Expand Up @@ -157,7 +156,7 @@ def _from_c(c_const):


class U64(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_I64"
size = 64
Expand Down Expand Up @@ -210,7 +209,7 @@ def __str__(self):


class F32(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_F32"
tag = "Ico_F32"
Expand All @@ -229,7 +228,7 @@ def _from_c(c_const):


class F32i(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_F32"
tag = "Ico_F32i"
Expand All @@ -248,7 +247,7 @@ def _from_c(c_const):


class F64(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_F64"
tag = "Ico_F64"
Expand All @@ -267,7 +266,7 @@ def _from_c(c_const):


class F64i(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_F64"
tag = "Ico_F64i"
Expand All @@ -286,7 +285,7 @@ def _from_c(c_const):


class V128(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_V128"
tag = "Ico_V128"
Expand All @@ -312,7 +311,7 @@ def _from_c(c_const):


class V256(IRConst):
__slots__: List[str] = []
__slots__: list[str] = []

type = "Ity_V256"
tag = "Ico_V256"
Expand Down
12 changes: 6 additions & 6 deletions pyvex/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List
from typing import Any

from .native import ffi, pvc
from .utils import stable_hash
Expand All @@ -9,7 +9,7 @@ class VEXObject:
The base class for Vex types.
"""

__slots__: List[str] = []
__slots__: list[str] = []

def __eq__(self, other):
if not isinstance(other, type(self)):
Expand Down Expand Up @@ -95,9 +95,9 @@ def _to_c(arr):
return pvc.mkIRRegArray(arr.base, get_int_from_enum(arr.elemTy), arr.nElems)


ints_to_enums: Dict[int, str] = {}
enums_to_ints: Dict[str, int] = {}
irop_enums_to_ints: Dict[str, int] = {}
ints_to_enums: dict[int, str] = {}
enums_to_ints: dict[str, int] = {}
irop_enums_to_ints: dict[str, int] = {}
will_be_overwritten = ["Ircr_GT", "Ircr_LT"]


Expand Down Expand Up @@ -137,7 +137,7 @@ def vex_endness_from_string(endness_str):
return getattr(pvc, endness_str)


def default_vex_archinfo() -> Dict[str, Any]:
def default_vex_archinfo() -> dict[str, Any]:
return {
"hwcaps": 0,
"endness": vex_endness_from_string("VexEndnessLE"),
Expand Down
10 changes: 5 additions & 5 deletions pyvex/expr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import re
from typing import Dict, List, Optional, Tuple
from typing import Optional

from .const import U8, U16, U32, U64, IRConst, get_type_size
from .enums import IRCallee, IRRegArray, VEXObject, get_enum_from_int, get_int_from_enum
Expand All @@ -17,7 +17,7 @@ class IRExpr(VEXObject):

__slots__ = []

tag: Optional[str] = None
tag: str | None = None
tag_int = 0 # set automatically at bottom of file

def pp(self):
Expand All @@ -30,7 +30,7 @@ def _pp_str(self) -> str:
raise NotImplementedError

@property
def child_expressions(self) -> List["IRExpr"]:
def child_expressions(self) -> list["IRExpr"]:
"""
A list of all of the expressions that this expression ends up evaluating.
"""
Expand Down Expand Up @@ -282,7 +282,7 @@ class Get(IRExpr):

tag = "Iex_Get"

def __init__(self, offset, ty: str, ty_int: Optional[int] = None):
def __init__(self, offset, ty: str, ty_int: int | None = None):
self.offset = offset
if ty_int is None:
self.ty_int = get_int_from_enum(ty)
Expand Down Expand Up @@ -762,7 +762,7 @@ def get_op_retty(op):
return op_arg_types(op)[0]


op_signatures: Dict[str, Tuple[str, Tuple[str, ...]]] = {}
op_signatures: dict[str, tuple[str, tuple[str, ...]]] = {}


def _request_op_type_from_cache(op):
Expand Down
8 changes: 4 additions & 4 deletions pyvex/lifting/lift_function.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from collections import defaultdict
from typing import DefaultDict, List, Optional, Type
from typing import DefaultDict

from pyvex import const
from pyvex.block import IRSB
Expand All @@ -15,8 +15,8 @@

log = logging.getLogger(__name__)

lifters: DefaultDict[str, List[Type[Lifter]]] = defaultdict(list)
postprocessors: DefaultDict[str, List[Type[Postprocessor]]] = defaultdict(list)
lifters: DefaultDict[str, list[type[Lifter]]] = defaultdict(list)
postprocessors: DefaultDict[str, list[type[Postprocessor]]] = defaultdict(list)


def lift(
Expand Down Expand Up @@ -74,7 +74,7 @@ def lift(
if isinstance(data, str):
raise TypeError("Cannot pass unicode string as data to lifter")

py_data: Optional[PyLiftSource]
py_data: PyLiftSource | None
if isinstance(data, (bytes, bytearray, memoryview)):
py_data = data
c_data = None
Expand Down

0 comments on commit de0972e

Please sign in to comment.