summaryrefslogtreecommitdiffstats
path: root/Tools/clinic
diff options
context:
space:
mode:
authorFurkan Onder <furkanonder@protonmail.com>2023-10-23 09:54:46 (GMT)
committerGitHub <noreply@github.com>2023-10-23 09:54:46 (GMT)
commit32c37fe1ba708b8290cfa971e130bcfc29f1ead3 (patch)
treecb2ea772b12098a174426a058203f6683a14d8e2 /Tools/clinic
parentc84b0390c053446b746b65ec82755918955e79e0 (diff)
downloadcpython-32c37fe1ba708b8290cfa971e130bcfc29f1ead3.zip
cpython-32c37fe1ba708b8290cfa971e130bcfc29f1ead3.tar.gz
cpython-32c37fe1ba708b8290cfa971e130bcfc29f1ead3.tar.bz2
gh-67565: Remove redundant C-contiguity checks (GH-105521)
Co-authored-by: Stefan Krah <skrah@bytereef.org>
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-xTools/clinic/clinic.py13
1 files changed, 1 insertions, 12 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 8a4bbcb..5f94b90a 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4605,15 +4605,12 @@ class Py_buffer_converter(CConverter):
return "".join(["if (", name, ".obj) {\n PyBuffer_Release(&", name, ");\n}\n"])
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None:
+ # PyBUF_SIMPLE guarantees that the format units of the buffers are C-contiguous.
if self.format_unit == 'y*':
return self.format_code("""
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
goto exit;
}}}}
- if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
- {bad_argument}
- goto exit;
- }}}}
""",
argname=argname,
bad_argument=self.bad_argument(displayname, 'contiguous buffer', limited_capi=limited_capi),
@@ -4632,10 +4629,6 @@ class Py_buffer_converter(CConverter):
if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{
goto exit;
}}}}
- if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
- {bad_argument}
- goto exit;
- }}}}
}}}}
""",
argname=argname,
@@ -4647,10 +4640,6 @@ class Py_buffer_converter(CConverter):
{bad_argument}
goto exit;
}}}}
- if (!PyBuffer_IsContiguous(&{paramname}, 'C')) {{{{
- {bad_argument2}
- goto exit;
- }}}}
""",
argname=argname,
bad_argument=self.bad_argument(displayname, 'read-write bytes-like object', limited_capi=limited_capi),