commit:     fa5153ff81b8159fa59dc2495f5bf9cdf36a99a4
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 12 10:49:25 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 12 10:49:25 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=fa5153ff

pquery: fix crash with verbose single uris attr

When the `uris` attribute has only one value, and the `verbose` option
was used, pquery was crashing because `node.uri` isn't subscriptable.
Use more agnostic `next(iter(node.uris))` instead.

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/scripts/pquery.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index 6bc04994d..eaba242f3 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -269,7 +269,7 @@ def format_attr(config, out, pkg, attr):
                 if not node.uri:
                     return False
                 if len(node.uri) == 1:
-                    out.write(node.uri[0], autoline=False)
+                    out.write(next(iter(node.uri)), autoline=False)
                     return False
                 out.write('|| (')
                 out.first_prefix.append('    ')

Reply via email to