public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/rpm] pmatilai-v6: - fix python match iterator regression wrt boolean representation
Date: Mon, 23 Nov 2026 09:26:35 GMT	[thread overview]
Message-ID: <179542599552.1.6037041824761707301.rpms-rpm-7d0e69f0b51d@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/rpm
Branch : pmatilai-v6
Commit : 7d0e69f0b51d09faf2eb4314a07a8af5e1154e2e
Author : Panu Matilainen <pmatilai@fedoraproject.org>
Date   : 2010-03-24T08:09:48+00:00
Stats  : +63/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/rpm/c/7d0e69f0b51d09faf2eb4314a07a8af5e1154e2e?branch=pmatilai-v6

Log:
- fix python match iterator regression wrt boolean representation

---
diff --git a/rpm-4.8.0-python-mibool.patch b/rpm-4.8.0-python-mibool.patch
new file mode 100644
index 0000000..18a9ce6
--- /dev/null
+++ b/rpm-4.8.0-python-mibool.patch
@@ -0,0 +1,57 @@
+commit 40f788a7bf3741f9c613ff302d4e1b0ceec2658c
+Author: Panu Matilainen <pmatilai@redhat.com>
+Date:   Wed Mar 24 09:53:25 2010 +0200
+
+    Add __bool__() / __nonzero__() method to python rpmmi objects (ticket #153)
+    - Objects supporting __len__() use (len > 0) for boolean representation,
+      which normally makes sense but as the match iterator count is often
+      zero despite the iterator actually existing and returning something,
+      and breaks existing code (rpmlint at least)
+    - Adding a __bool__() (known as __nonzero__() in Python < 3) method
+      returning true for non-NULL iterator fixes this and gives more
+      meaningful answers than pre 4.8.0 which simply always returned True
+
+diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c
+index f6dd802..b7bfb1b 100644
+--- a/python/rpmmi-py.c
++++ b/python/rpmmi-py.c
+@@ -137,11 +137,30 @@ static Py_ssize_t rpmmi_length(rpmmiObject * s)
+     return s->mi ? rpmdbGetIteratorCount(s->mi) : 0;
+ }
+ 
++static int rpmmi_bool(rpmmiObject *s)
++{
++    return (s->mi != NULL);
++}
++
+ PyMappingMethods rpmmi_as_mapping = {
+     (lenfunc) rpmmi_length,		/* mp_length */
+     0,
+ };
+ 
++static PyNumberMethods rpmmi_as_number = {
++	0, /* nb_add */
++	0, /* nb_subtract */
++	0, /* nb_multiply */
++	0, /* nb_divide */
++	0, /* nb_remainder */
++	0, /* nb_divmod */
++	0, /* nb_power */
++	0, /* nb_negative */
++	0, /* nb_positive */
++	0, /* nb_absolute */
++	(inquiry)rpmmi_bool, /* nb_bool/nonzero */
++};
++
+ static char rpmmi_doc[] =
+ "";
+ 
+@@ -156,7 +175,7 @@ PyTypeObject rpmmi_Type = {
+ 	0,				/* tp_setattr */
+ 	0,				/* tp_compare */
+ 	0,				/* tp_repr */
+-	0,				/* tp_as_number */
++	&rpmmi_as_number,		/* tp_as_number */
+ 	0,				/* tp_as_sequence */
+ 	&rpmmi_as_mapping,		/* tp_as_mapping */
+ 	0,				/* tp_hash */

diff --git a/rpm.spec b/rpm.spec
index 201b3b9..5ea6eef 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -21,7 +21,7 @@
 Summary: The RPM package management system
 Name: rpm
 Version: %{rpmver}
-Release: 12%{?dist}
+Release: 13%{?dist}
 Group: System Environment/Base
 Url: http://www.rpm.org/
 Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2
@@ -49,6 +49,7 @@ Patch204: rpm-4.8.0-lazy-statfs.patch
 Patch205: rpm-4.8.0-erasure-dsi.patch
 Patch206: rpm-4.8.0-prep-keep-empty.patch
 Patch207: rpm-4.8.0-python-nocontexts.patch
+Patch208: rpm-4.8.0-python-mibool.patch
 
 # These are not yet upstream
 Patch301: rpm-4.6.0-niagara.patch
@@ -203,6 +204,7 @@ packages on a system.
 %patch205 -p1 -b .erasure-dsi
 %patch206 -p1 -b .prep-keep-empty
 %patch207 -p1 -b .python-nocontexts
+%patch208 -p1 -b .python-mibool
 
 %patch301 -p1 -b .niagara
 %patch302 -p1 -b .geode
@@ -419,6 +421,9 @@ exit 0
 %doc doc/librpm/html/*
 
 %changelog
+* Wed Mar 24 2010 Panu Matilainen <pmatilai@redhat.com> - 4.8.0-13
+- fix python match iterator regression wrt boolean representation
+
 * Wed Mar 17 2010 Panu Matilainen <pmatilai@redhat.com> - 4.8.0-12
 - unbreak find-lang --with-man from yesterdays braindamage
 

                 reply	other threads:[~2026-11-23  9:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179542599552.1.6037041824761707301.rpms-rpm-7d0e69f0b51d@fedoraproject.org \
    --to=pmatilai@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox