Skip to content

Commit 0fa556c

Browse files
committed
patch #19
1 parent 98dcace commit 0fa556c

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ site/
77
.mypy_cache/
88
.pytest_cache/
99
test.py
10-
.vscode/
10+
.vscode/
11+
vgcore.*

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if __name__ == "__main__":
77
setup(
88
name="pointers.py",
9-
version="1.3.8",
9+
version="1.3.9",
1010
author="ZeroIntensity",
1111
author_email="<zintensitydev@gmail.com>",
1212
description="Bringing the hell of pointers to Python.",

src/pointers/bindings.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,9 @@ def _make_char_pointer(data: StringLike) -> Union[bytes, ctypes.c_char_p]:
254254

255255
def _make_format(*args: Format) -> Iterator[Format]:
256256
for i in args:
257-
for x in {VoidPointer, str, bytes}:
258-
if isinstance(i, x):
259-
yield _make_char_pointer(i) # type: ignore
260-
continue
257+
if isinstance(i, (VoidPointer, str, bytes)):
258+
yield _make_char_pointer(i) # type: ignore
259+
continue
261260

262261
yield i
263262

@@ -466,7 +465,7 @@ def sprintf(string: StringLike, fmt: StringLike, *args: Format) -> int:
466465
dll.sprintf,
467466
_make_char_pointer(string),
468467
_make_char_pointer(fmt),
469-
*args,
468+
*_make_format(*args),
470469
)
471470

472471

@@ -475,7 +474,7 @@ def fscanf(stream: PointerLike, fmt: StringLike, *args: Format) -> int:
475474
dll.fscanf,
476475
stream,
477476
_make_char_pointer(fmt),
478-
*args,
477+
*_make_format(*args),
479478
)
480479

481480

@@ -488,7 +487,7 @@ def sscanf(string: StringLike, fmt: StringLike, *args: Format) -> int:
488487
dll.sscanf,
489488
_make_char_pointer(string),
490489
_make_char_pointer(fmt),
491-
*args,
490+
*_make_format(*args),
492491
)
493492

494493

src/pointers/c_pointer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def _make_stream_and_ptr(
116116

117117
return self.make_ct_pointer(), bytes(bytes_a)
118118

119-
def move(self, data: Pointer[Any], unsafe: bool = False) -> None:
120-
"""Move data to the allocated memory."""
119+
def move(self, data: Pointer[T], unsafe: bool = False) -> None:
120+
"""Move C data to the target memory."""
121121
if not isinstance(data, _BaseCPointer):
122122
raise ValueError(
123123
f'"{type(data).__name__}" object is not a valid C pointer',
@@ -208,7 +208,7 @@ def make_py(cls, data: "ctypes._CData"):
208208

209209
return res
210210

211-
def __lshift__(self, data: Any):
211+
def __lshift__(self, data: T):
212212
"""Move data from another pointer to this pointer.""" # noqa
213213
self.move(data if isinstance(data, _BaseCPointer) else to_c_ptr(data))
214214
return self
@@ -218,8 +218,8 @@ class VoidPointer(_BaseCPointer[int]):
218218
"""Class representing a void pointer to a C object."""
219219

220220
@property
221-
def _as_parameter_(self) -> int:
222-
return self.address
221+
def _as_parameter_(self) -> ctypes.c_void_p:
222+
return ctypes.c_void_p(self.address)
223223

224224
def dereference(self) -> Optional[int]:
225225
"""Dereference the pointer."""

0 commit comments

Comments
 (0)