-
Notifications
You must be signed in to change notification settings - Fork 126
refactor: Use functions from limited API #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Shouldn't this also enable the limited API so the changes are exercised immediately? |
This PR only replaces a few functions that are outside the limited API set. I have split my original work into smaller chunks, that are easier to understand and review. There is a bunch of more work to do before I can enable the limited API, e.g. port LDAP_Type to heap type. |
Right I assumed it was considered ready for review, not a draft? |
I don't follow. This PR is not a draft and is ready for review. I'm sorry if I wasn't clear. I want to split the work on #540 into small, digestible chunks. Each PR will improve and change one aspect of the code base. Every PR will also leave the code base in working conditions with all tests passing. This approach makes it easier for you and @droideck to review and verify the changes. Some changes are not obvious unless you are familiar with stable ABI and module states. I estimate that #540 is going to take around 6 to 7 PRs in total. |
Hmm, sure, but at this point how do I tell whether the PR is useful? It gives no clear way to see if something has been missed for one. I can see #540 is large and you want to split it into different parts (and get your point there) but I'd still expect each PR to be a patchset with a clear intent along the path that gets realised (somewhat) by the end of it, not necessarily one patch per PR if that makes sense? This PR as it stands looks like one commit that can't be reviewed alone, which might change if more commits were added to it (e.g. being able to limit ourselves to the stable ABI for 3.x+ and enforcing that). You are welcome to disagree but then I'll have to recuse myself from reviewing this. |
bad8aef
to
b45e0c3
Compare
But this PR has a clear intent; it replaces several macros, one function, and one case of direct struct access with features from the limited API. To review the PR, you look up the documentation of each replaced function / macro, check that the old code is not marked for You could argue that my patch may be missing some function replacements. That's not a problem, we can address that in another commit. The important bit is that this PR does not introduce a regression. |
b45e0c3
to
c37d196
Compare
Replace unsafe macros and direct struct access with functions from the subset of limited API functions. * `PySequence_Fast_GET_ITEM` -> `PySequence_GetItem` * `PyTuple_SET_ITEM` -> `PyTuple_SetItem` * `PyList_SET_ITEM` -> `PyList_SetItem` * `PyUnicode_AsUTF8AndSize` -> `PyUnicode_AsUTF8String` + `PyBytes_AsStringAndSize`. The function `PyUnicode_AsUTF8AndSize` is not in limited API before Python 3.10. * `const char *tp_name` -> `Py_TYPE()` string representation See: python-ldap#540 Signed-off-by: Christian Heimes <cheimes@redhat.com>
c37d196
to
5d49f27
Compare
Replace unsafe macros and direct struct access with functions from the subset of limited API functions.
PySequence_Fast_GET_ITEM
->PySequence_GetItem
PyTuple_SET_ITEM
->PyTuple_SetItem
PyList_SET_ITEM
->PyList_SetItem
PyUnicode_AsUTF8AndSize
->PyUnicode_AsUTF8String
+PyBytes_AsStringAndSize
. The functionPyUnicode_AsUTF8AndSize
is not in limited API before Python 3.10.const char *tp_name
->Py_TYPE()
string representationSee: #540