[Rpm-maint] [rpm-software-management/rpm] Support rpmver-py comparison operator inheritance (PR #2839)
Hi again, I'm opening this PR due to the main issue I found when writing a `rpm.ver` subclass in python: Trying to compare different subclass instances would raise a `NotImplementedError` while it was supported on base class instances. The reason behind that was that the `verObject_Check` macro checked for operand types to be the same as `rpm.ver`. A way to overcome that, is checking their types are subclasses of `rpm.ver`, or simply calling `PyObject_TypeCheck`. I'm proposing this patch only targeting the `rpm.ver` type as I'm not sure if such behavior was intended in the first place. In fact, most of the python bindings seem to follow the same type check pattern. Moreover, although not directly related to `rpm.ver` (but `rpm.ts`), I found a similar proposal was made but not merged in #1600. In case you consider this to be valid proposal and that it could be helpful for other python bindings, I could try to provide a more general patch as well. Thank you for the attention once again! You can view, comment on, or merge this pull request online at: https://github.com/rpm-software-management/rpm/pull/2839 -- Commit Summary -- * Support rpmver-py comparison operator inheritance -- File Changes -- M python/rpmver-py.h (2) M tests/rpmpython.at (27) -- Patch Links -- https://github.com/rpm-software-management/rpm/pull/2839.patch https://github.com/rpm-software-management/rpm/pull/2839.diff -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/2839 You are receiving this because you are subscribed to this thread. Message ID:___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
Re: [Rpm-maint] [rpm-software-management/rpm] Return false when comparing different python objects holding the same version tag (PR #2838)
Yeah, I'd have assumed the same thing actually, that's why it was weird to me to see `!=` wasn't acting as a complement of `==` :sweat_smile:(now I've just found why that was intended [0]). I guess that it just implements a `is not` by default? I'm not sure. No problem, thank you for the quick reply! [0] https://peps.python.org/pep-0207/#proposed-resolutions (point 3) -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/2838#issuecomment-1886833169 You are receiving this because you are subscribed to this thread. Message ID: ___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint
[Rpm-maint] [rpm-software-management/rpm] Return false when comparing different python objects holding the same version tag (PR #2838)
Hello! While I was working on another issue, I found that the inequality operator of python `rpm.ver` objects would not work as I was expecting to. `!=` would always return `True` if the compared objects were not the actual same python object. That was leading to situations as ```python (v := rpm.ver('1.0')) != v# False, we are comparing the object with itself rpm.ver('1.0') != rpm.ver('1.0') # True, although they hold the same version tag string ``` I'm not sure whether that was the intended behavior or not. It was not quite what I expected when I tried applying the operator. I didn't research the topic really exhaustively, but I couldn't find related issues at least in the PRs of this repo. Anyway, this patch adds the `PY_NE` case to the `tp_richcompare` slot function and adds some extra checks to a related existing test. Thanks for the attention! :smile: cc: @luckyh You can view, comment on, or merge this pull request online at: https://github.com/rpm-software-management/rpm/pull/2838 -- Commit Summary -- * Add rpmver-py inequality operator -- File Changes -- M python/rpmver-py.c (3) M tests/rpmpython.at (6) -- Patch Links -- https://github.com/rpm-software-management/rpm/pull/2838.patch https://github.com/rpm-software-management/rpm/pull/2838.diff -- Reply to this email directly or view it on GitHub: https://github.com/rpm-software-management/rpm/pull/2838 You are receiving this because you are subscribed to this thread. Message ID:___ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint