Skip to content

Commit 8c05c5d

Browse files
committed
clean up error messages
RawKernelArg and WorkGroupMemory error messages were incorrectly formatted
1 parent ad14818 commit 8c05c5d

1 file changed

Lines changed: 27 additions & 18 deletions

File tree

dpctl/_sycl_queue.pyx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,25 +1703,28 @@ cdef class WorkGroupMemory:
17031703
raise RuntimeError("Workgroup memory extension not available")
17041704

17051705
if not (0 < len(args) < 3):
1706-
raise TypeError("WorkGroupMemory constructor takes 1 or 2 "
1707-
f"arguments, but {len(args)} were given")
1706+
raise TypeError(
1707+
"WorkGroupMemory constructor takes 1 or 2 arguments, but "
1708+
f"{len(args)} were given"
1709+
)
17081710

17091711
if len(args) == 1:
17101712
if not isinstance(args[0], numbers.Integral):
1711-
raise TypeError("WorkGroupMemory single argument constructor"
1712-
"expects first argument to be `int`",
1713-
f"but got {type(args[0])}")
1713+
raise TypeError(
1714+
"WorkGroupMemory single argument constructor expects "
1715+
f"first argument to be `int` but got {type(args[0])}"
1716+
)
17141717
nbytes = <size_t>(args[0])
17151718
else:
17161719
if not isinstance(args[0], str):
17171720
raise TypeError(
1718-
"WorkGroupMemory constructor expects first"
1719-
f"argument to be `str`, but got {type(args[0])}"
1721+
"WorkGroupMemory constructor expects first argument to be "
1722+
f"`str`, but got {type(args[0])}"
17201723
)
17211724
if not isinstance(args[1], numbers.Integral):
17221725
raise TypeError(
1723-
"WorkGroupMemory constructor expects second"
1724-
f"argument to be `int`, but got {type(args[1])}"
1726+
"WorkGroupMemory constructor expects second argument to "
1727+
f"be `int`, but got {type(args[1])}"
17251728
)
17261729
dtype = <str>(args[0])
17271730
count = <size_t>(args[1])
@@ -1800,14 +1803,16 @@ cdef class RawKernelArg:
18001803
raise RuntimeError("Raw kernel arg extension not available")
18011804

18021805
if not (0 < len(args) < 3):
1803-
raise TypeError("RawKernelArg constructor takes 1 or 2 "
1804-
f"arguments, but {len(args)} were given")
1806+
raise TypeError(
1807+
"RawKernelArg constructor takes 1 or 2 arguments, but "
1808+
f"{len(args)} were given"
1809+
)
18051810

18061811
if len(args) == 1:
18071812
if not _is_buffer(args[0]):
1808-
raise TypeError("RawKernelArg single argument constructor"
1809-
"expects argument to be buffer",
1810-
f"but got {type(args[0])}")
1813+
raise TypeError(
1814+
"RawKernelArg single argument constructor expects "
1815+
f"argument to be buffer but got {type(args[0])}")
18111816

18121817
ret_code = PyObject_GetBuffer(args[0], &(_buffer),
18131818
PyBUF_SIMPLE | PyBUF_ANY_CONTIGUOUS)
@@ -1819,11 +1824,15 @@ cdef class RawKernelArg:
18191824
_is_buf = True
18201825
else:
18211826
if not isinstance(args[0], numbers.Integral):
1822-
raise TypeError("RawKernelArg constructor expects first"
1823-
"argument to be `int`, but got {type(args[0])}")
1827+
raise TypeError(
1828+
"RawKernelArg constructor expects first argument to be "
1829+
f"`int`, but got {type(args[0])}"
1830+
)
18241831
if not isinstance(args[1], numbers.Integral):
1825-
raise TypeError("RawKernelArg constructor expects second"
1826-
"argument to be `int`, but got {type(args[1])}")
1832+
raise TypeError(
1833+
"RawKernelArg constructor expects second argument to be "
1834+
f"`int`, but got {type(args[1])}"
1835+
)
18271836

18281837
_is_buf = False
18291838
count = args[0]

0 commit comments

Comments
 (0)