-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use apigen to generate cython.
- Loading branch information
Showing
23 changed files
with
1,709 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ | |
*.o | ||
*.tox | ||
.mypy_cache | ||
# TODO(iphydf): Remove once .gen is removed from the name. | ||
*.gen.pyx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from enum import Enum | ||
from typing import Sized | ||
from typing import TypeVar | ||
|
||
T = TypeVar("T", bytes, str, Sized) | ||
|
||
|
||
class PytoxException(Exception): | ||
pass | ||
|
||
|
||
class ApiException(PytoxException): | ||
def __init__(self, err: Enum): | ||
super().__init__(err.name) | ||
self.error = err | ||
|
||
|
||
class LengthException(PytoxException): | ||
pass | ||
|
||
|
||
class UseAfterFreeException(Exception): | ||
def __init__(self): | ||
super().__init__( | ||
"object used after it was killed/freed (or it was never initialised)" | ||
) | ||
|
||
|
||
def _check_len(name: str, data: T, expected_length: int) -> T: | ||
if len(data) < expected_length: | ||
raise LengthException( | ||
f"parameter '{name}' received bytes of invalid" | ||
f"length {len(data)}, expected at least {expected_length}") | ||
return data |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.