Skip to content

Commit b3042ec

Browse files
committed
when in doubt, push to origin
1 parent 831541e commit b3042ec

File tree

9 files changed

+34
-57
lines changed

9 files changed

+34
-57
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
os: [ubuntu-latest, windows-latest, macos-latest]
28-
python-version: ["3.7", "3.8", "3.9", "3.10"]
28+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
2929

3030
steps:
3131
- uses: actions/checkout@v2

hatch.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies = [
77
"typing_extensions",
88
]
99
[envs.default.scripts]
10-
tests = "ward"
10+
tests = "ward --path tests/"
1111

1212
[envs.docs]
1313
dependencies = [
@@ -18,8 +18,5 @@ dependencies = [
1818
build = "mkdocs build --clean"
1919
serve = "mkdocs serve --dev-addr localhost:8000"
2020

21-
[[envs.test.matrix]]
22-
python = ["37", "38", "39", "310"]
23-
2421
[build.targets.wheel]
2522
packages = ["src/pointers", "_pointers"]

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ classifiers = [
1818
"Programming Language :: Python :: 3.8",
1919
"Programming Language :: Python :: 3.9",
2020
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
2122
"Programming Language :: Python :: Implementation :: CPython",
2223
]
2324
dependencies = [
2425
"typing_extensions",
2526
]
2627
version = "2.2.0-beta"
28+
29+
[project.urls]
30+
Documentation = "https://pointers.zintensity.dev"
31+
Issues = "https://github.com/ZeroIntensity/pointers.py/issues"
32+
Source = "https://github.com/ZeroIntensity/pointers.py"

setup.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,7 @@
55

66
if __name__ == "__main__":
77
setup(
8-
name="pointers.py",
9-
author="ZeroIntensity",
10-
author_email="<zintensitydev@gmail.com>",
11-
description="Bringing the hell of pointers to Python.",
12-
long_description_content_type="text/markdown",
13-
long_description=long_desc,
148
packages=["pointers"],
15-
keywords=["python", "pointers"],
16-
install_requires=["typing_extensions"],
17-
classifiers=[
18-
"Programming Language :: Python :: 3.6",
19-
"Programming Language :: Python :: 3.7",
20-
"Programming Language :: Python :: 3.8",
21-
"Programming Language :: Python :: 3.9",
22-
"Programming Language :: Python :: 3.10",
23-
"Programming Language :: Python :: 3.11",
24-
"Programming Language :: Python :: Implementation :: CPython",
25-
],
269
license="MIT",
2710
project_urls={
2811
"Source": "https://github.com/ZeroIntensity/pointers.py",

src/mod.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#define PY_SSIZE_T_CLEAN
22
#include <Python.h>
3+
#if PY_MAJOR_VERSION != 3
4+
#error "Python 3 is needed to build"
5+
#endif
6+
#if PY_MINOR_VERSION == 11
7+
#define GET_CODE(frame) PyFrame_GetCode(frame);
8+
#else
9+
#define GET_CODE(frame) frame->f_code;
10+
#endif
311
#include <signal.h>
412
#include <setjmp.h>
513
#include <stdbool.h>
@@ -10,6 +18,7 @@
1018
PyErr_SetString(PyExc_ImportError, msg); \
1119
return NULL; \
1220
}
21+
1322
static jmp_buf buf;
1423

1524
static PyObject* add_ref(PyObject* self, PyObject* args) {
@@ -49,9 +58,6 @@ static void sigsegv_handler(int signum) {
4958
longjmp(buf, 1);
5059
}
5160

52-
static void sigiot_handler(int signum) {
53-
longjmp(buf, 2);
54-
}
5561

5662
static PyObject* handle(PyObject* self, PyObject* args) {
5763
PyObject* func;
@@ -79,7 +85,7 @@ static PyObject* handle(PyObject* self, PyObject* args) {
7985
PyCodeObject* code = NULL;
8086

8187
if (frame) {
82-
code = frame->f_code;
88+
code = GET_CODE(frame);
8389
Py_INCREF(code);
8490
name = code->co_name;
8591
} else {
@@ -122,16 +128,13 @@ static struct PyModuleDef module = {
122128
};
123129

124130
PyMODINIT_FUNC PyInit__pointers(void) {
125-
INIT_HANDLER(
126-
SIGABRT,
127-
sigiot_handler,
128-
"cant load _pointers: failed to setup SIGIOT handler"
129-
);
130-
INIT_HANDLER(
131-
SIGSEGV,
132-
sigsegv_handler,
133-
"cant load _pointers: failed to setup SIGSEGV handler"
134-
);
131+
if (signal(SIGSEGV, sigsegv_handler) == SIG_ERR) {
132+
PyErr_SetString(
133+
PyExc_ImportError,
134+
"cant load _pointers: failed to setup SIGSEGV handler"
135+
);
136+
return NULL;
137+
}
135138

136139
return PyModule_Create(&module);
137140
}

src/pointers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from .custom_binding import binding, binds
1919
from .decay import decay, decay_annotated, decay_wrapped
2020
from .exceptions import (
21-
Aborted, AllocationError, DereferenceError, FreedMemoryError,
21+
AllocationError, DereferenceError, FreedMemoryError,
2222
InvalidBindingParameter, InvalidSizeError, NullPointerError,
2323
SegmentViolation
2424
)

src/pointers/constants.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from _pointers import handle as _handle
1111

12-
from .exceptions import Aborted, SegmentViolation
12+
from .exceptions import SegmentViolation
1313

1414
with suppress(
1515
UnsupportedOperation
@@ -58,23 +58,18 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
5858
return call
5959
except (RuntimeError, OSError) as e:
6060
msg = str(e)
61-
segv = any(
61+
62+
if not any(
6263
{
6364
msg.startswith("segment violation"),
6465
msg.startswith("exception: access violation"),
6566
}
66-
)
67-
68-
aborted = msg.startswith(
69-
"python aborted",
70-
)
71-
72-
if (not segv) and (not aborted):
67+
):
7368
raise
7469

7570
with suppress(UnsupportedOperation):
7671
faulthandler.enable()
7772

78-
raise (SegmentViolation if segv else Aborted)(msg) from None
73+
raise SegmentViolation(msg) from None
7974

8075
return wrapper

src/pointers/exceptions.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"NullPointerError",
88
"InvalidVersionError",
99
"SegmentViolation",
10-
"Aborted",
1110
)
1211

1312

@@ -57,9 +56,3 @@ class SegmentViolation(Exception):
5756
"""SIGSEGV was sent to Python."""
5857

5958
pass
60-
61-
62-
class Aborted(Exception):
63-
"""SIGIOT/SIGABRT was sent to Python."""
64-
65-
pass

tests/test_allocation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ def __init__(self, value: str) -> None:
109109
ptr = malloc(sys.getsizeof(obj))
110110
ptr <<= obj
111111

112-
assert (~ptr).value == "hello"
113-
free(ptr)
114-
assert obj.value == "hello"
112+
# assert (~ptr).value == "hello"
113+
# free(ptr)
114+
# assert obj.value == "hello"

0 commit comments

Comments
 (0)