Skip to content
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

TypeError: 'gi._gi.GPropsIter' object is not iterable #330

Open
carlosal1015 opened this issue Dec 23, 2024 · 8 comments
Open

TypeError: 'gi._gi.GPropsIter' object is not iterable #330

carlosal1015 opened this issue Dec 23, 2024 · 8 comments
Labels
bug external dependency Progress on this issue is blocked by a bug or lacking feature in software on which we depend

Comments

@carlosal1015
Copy link

Describe the bug

When I start the program with python 3.13 we have the following error

$ pympress 
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/pympress/app.py", line 164, in do_activate
    self.gui = ui.UI(self, self.config)
               ~~~~~^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/pympress/ui.py", line 212, in __init__
    self.load_ui('presenter')
    ~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/pympress/builder.py", line 186, in load_ui
    self.__translate_widget_strings(obj)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/lib/python3.13/site-packages/pympress/builder.py", line 79, in __translate_widget_strings
    for str_prop in (prop.name for prop in a_widget.props if prop.value_type == GObject.TYPE_STRING):
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/pympress/builder.py", line 79, in <genexpr>
    for str_prop in (prop.name for prop in a_widget.props if prop.value_type == GObject.TYPE_STRING):
                                           ^^^^^^^^^^^^^^
TypeError: 'gi._gi.GPropsIter' object is not iterable

To Reproduce
Steps to reproduce the behavior:

  1. Start pympress from terminal.

Expected behavior

Open the gui.

Environment (please complete the following information):

@Cimbali
Copy link
Owner

Cimbali commented Dec 23, 2024

The properties iterator is not iterable… that’s interesting. Can you share the 2 first lines of your log file? It should give all the detailed versions of dependencies – Gtk etc.

@carlosal1015
Copy link
Author

I am not sure where is located the log file, over ~/.config no directory called pympress.

➜  ~ pacman -Qi python-pympress 
Name            : python-pympress
Version         : 1.8.5-2
Description     : Simple and powerful dual-screen PDF reader designed for presentations
Architecture    : any
URL             : https://github.com/Cimbali/pympress
Licenses        : GPL-2.0-or-later
Groups          : None
Provides        : None
Depends On      : poppler-glib  gtk3  python-cairo  gdk-pixbuf2  python-gobject  gobject-introspection  python-watchdog  perl-x11-protocol  perl-net-dbus
Optional Deps   : vlc: for playing videos [installed]
                  python-vlc: for playing videos
                  gstreamer: for playing videos [installed]
                  gst-plugin-gtk: for playing videos
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 823.82 KiB
Packager        : Unknown Packager
Build Date      : Sun 22 Dec 2024 03:40:14 PM -05
Install Date    : Sun 22 Dec 2024 04:28:39 PM -05
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : None

@Cimbali
Copy link
Owner

Cimbali commented Dec 25, 2024

Logs should be under ~/.cache but you've already given all the info I was looking for. Will try to reproduce

@carlosal1015
Copy link
Author

carlosal1015 commented Dec 25, 2024

Yes, there is ~/.cache/pympress.log .

pympress.log

@carlosal1015
Copy link
Author

carlosal1015 commented Dec 25, 2024

Logs should be under ~/.cache but you've already given all the info I was looking for. Will try to reproduce

With docker is easy to reproduce

$ docker run -it --rm archlinux:base-devel
useradd -l -md /home/aur -s /bin/bash aur
passwd -d aur
echo 'aur ALL=(ALL) ALL' > /etc/sudoers.d/aur
pacman --noconfirm -Syu git xorg-server-xvfb
su aur
cd ~
git clone https://aur.archlinux.org/python-pympress.git
cd python-pympress
makepkg --noconfirm -si
sudo Xvfb :5 &
DISPLAY=:5 pympress
cat ~/.cache/pympress.log

asciicast

@Cimbali
Copy link
Owner

Cimbali commented Dec 26, 2024

Ok this is technically a bug in GPropsIter which is missing its required __iter__ function (it only has __next__). I’d prefer to see it fixed upstream rather than add a workaround in code, as that would also not be guaranteed to be future-proof.

Temporary fixes are:

  • use python ≤ 3.12
  • change line 79 in builder.py as follows:
    --- i/pympress/builder.py
    +++ w/pympress/builder.py
    @@ -76,7 +76,7 @@ class Builder(Gtk.Builder):
             Args:
                 a_widget (:class:`~GObject.Object`): an object built by the builder, usually a widget
             """
    -        for str_prop in (prop.name for prop in a_widget.props if prop.value_type == GObject.TYPE_STRING):
    +        for str_prop in (prop.name for prop in list(a_widget.props) if prop.value_type == GObject.TYPE_STRING):
                 try:
                     str_val = getattr(a_widget.props, str_prop)
                     if str_val:

(i.e. don’t rely on the conversion to an iterator.)

This patch can be added in AUR or wherever people use python 3.13 early. If I see no movement to fix the issue in GObject I’ll merge this in main.

@Cimbali Cimbali added bug external dependency Progress on this issue is blocked by a bug or lacking feature in software on which we depend labels Dec 26, 2024
@carlosal1015
Copy link
Author

Thanks, just in time for my talk today 😄

It is working and was patched in AUR.
image

@Cimbali Cimbali reopened this Dec 26, 2024
@Cimbali
Copy link
Owner

Cimbali commented Dec 26, 2024

Great! Let's keep this open for now to not forget about it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug external dependency Progress on this issue is blocked by a bug or lacking feature in software on which we depend
Projects
None yet
Development

No branches or pull requests

2 participants