-
Notifications
You must be signed in to change notification settings - Fork 144
Fix a segfault in iterator of a ConfigParser section #1682
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
Fix a segfault in iterator of a ConfigParser section #1682
Conversation
FWIW I tried to research a better way to return |
@@ -71,10 +71,6 @@ template<class T> | |||
class Iterator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: I am not entirely sure why this class exists in this file as well.
An iterator should return self on __iter__. So that this works: >>> it1 = iter(sectObj) >>> it2 = iter(it1) >>> it1 is it2 True Previously, this iterator did not return self on __iter__, it was like this: class PreserveOrderMapStringStringIterator(object): ... def __iter__(self): return _common_types.PreserveOrderMapStringStringIterator___iter__(self) And that returned a new Python object. This fixes https://bugzilla.redhat.com/2330562 by avoiding a second iterator object. My SWIG skills are close to zero, perhaps this is not the best way to return self, but it seems to work.
dnf5 has the entire Iterator written in Python which might be a possible solution as well: https://github.com/rpm-software-management/dnf5/blob/ff1ac05c43a4fbf022aedaeef9b6ba49a47a4e1f/bindings/libdnf5/common.i#L104C7-L104C15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
f3302a8
into
rpm-software-management:dnf-4-master
This is a follow-up to rpm-software-management/libdnf#1682. Reported bug: https://bugzilla.redhat.com/show_bug.cgi?id=2330562
This is a follow-up to rpm-software-management/libdnf#1682. Reported bug: https://bugzilla.redhat.com/show_bug.cgi?id=2330562
This is a follow-up to rpm-software-management/libdnf#1682. Reported bug: https://bugzilla.redhat.com/show_bug.cgi?id=2330562
This is a follow-up to rpm-software-management/libdnf#1682. Reported bug: https://bugzilla.redhat.com/show_bug.cgi?id=2330562
An iterator should return self on
__iter__
.So that this works:
Previously, this iterator did not return self on
__iter__
, it was like this:And that returned a new Python object.
This fixes https://bugzilla.redhat.com/2330562 by avoiding a second iterator object.
My SWIG skills are close to zero,
perhaps this is not the best way to return self, but it seems to work.