From 0f0c5d69e56f66e0ed7788058c31f423c6b08aab Mon Sep 17 00:00:00 2001 From: mara004 Date: Wed, 17 Jan 2024 14:52:12 +0100 Subject: [PATCH 1/3] CLI: fix {compile,runtime}_libdirs mutilation (#203) Amends #161 See https://github.com/ctypesgen/ctypesgen/pull/161#discussion_r1438930554 for explanation --- ctypesgen/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ctypesgen/__main__.py b/ctypesgen/__main__.py index 32c2e78c..668a9858 100644 --- a/ctypesgen/__main__.py +++ b/ctypesgen/__main__.py @@ -327,8 +327,10 @@ def main(givenargs=None): parser.set_defaults(**core_options.default_values) args = parser.parse_args(givenargs) - args.compile_libdirs += args.universal_libdirs - args.runtime_libdirs += args.universal_libdirs + # Important: don't use +=, it modifies the original list instead of + # creating a new one. This can be problematic with repeated API calls. + args.compile_libdirs = args.compile_libdirs + args.universal_libdirs + args.runtime_libdirs = args.runtime_libdirs + args.universal_libdirs # Figure out what names will be defined by imported Python modules args.other_known_names = find_names_in_modules(args.modules) From 1b0e993fe9fa8df5f6023ed323fc7f01cfbf7e2d Mon Sep 17 00:00:00 2001 From: mara004 Date: Mon, 26 Feb 2024 14:26:51 +0100 Subject: [PATCH 2/3] ctypedescs: remove spurious APR types from type map These seem to be custom types from the APR library, which don't belong in a generic type map. I descended git blame, but these lines predate the main history. Given commit 3d2d980, I'd guess APR may have been @davidjamesca's use case. This is a backport of https://github.com/pypdfium2-team/ctypesgen/commit/fd31029e9f344131eb0f1fa5f55231741b5a0c16 --- ctypesgen/ctypedescs.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ctypesgen/ctypedescs.py b/ctypesgen/ctypedescs.py index 4b058504..57144b99 100755 --- a/ctypesgen/ctypedescs.py +++ b/ctypesgen/ctypedescs.py @@ -66,9 +66,7 @@ ("int", True, 2): "c_longlong", ("int", False, 2): "c_ulonglong", ("size_t", True, 0): "c_size_t", - ("apr_int64_t", True, 0): "c_int64", ("off64_t", True, 0): "c_int64", - ("apr_uint64_t", False, 0): "c_uint64", ("wchar_t", True, 0): "c_wchar", ("ptrdiff_t", True, 0): "c_ptrdiff_t", # Requires definition in preamble ("ssize_t", True, 0): "c_ptrdiff_t", # Requires definition in preamble From b86cad7e9e549160d68a1c1cbc8cb4693c917270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:05:13 -0400 Subject: [PATCH 3/3] style: Manual fixes for single-line-implicit-string-concatenation violations (ISC001) --- ctypesgen/expressions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctypesgen/expressions.py b/ctypesgen/expressions.py index c4fd7390..3ceeec21 100644 --- a/ctypesgen/expressions.py +++ b/ctypesgen/expressions.py @@ -135,7 +135,7 @@ def evaluate(self, context): if self.op: return self.op(self.child.evaluate(context)) else: - raise ValueError('The C operator "%s" can\'t be evaluated right ' "now" % self.name) + raise ValueError('The C operator "%s" can\'t be evaluated right now' % self.name) def py_string(self, can_be_ctype): return self.format % self.child.py_string(self.child_can_be_ctype and can_be_ctype) @@ -182,7 +182,7 @@ def evaluate(self, context): if self.op: return self.op(self.left.evaluate(context), self.right.evaluate(context)) else: - raise ValueError('The C operator "%s" can\'t be evaluated right ' "now" % self.name) + raise ValueError('The C operator "%s" can\'t be evaluated right now' % self.name) def py_string(self, can_be_ctype): return self.format % (