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

Error with dbus type conversion on recent upgrade #477

Closed
matclab opened this issue Nov 18, 2019 · 14 comments
Closed

Error with dbus type conversion on recent upgrade #477

matclab opened this issue Nov 18, 2019 · 14 comments

Comments

@matclab
Copy link

matclab commented Nov 18, 2019

I just upgraded Arch linux with

  • python 3.8
  • pygtk 2.24.0
  • python-dbus 1.2.12

Running master I get the following errors:

  • in hamster-cli
Traceback (most recent call last):
  File "/home/clabaut/contrib/hamster/src/hamster/edit_activity.py", line 375, in on_save_button_clicked
    runtime.storage.update_fact(self.fact_id, self.fact)
  File "/home/clabaut/contrib/hamster/src/hamster/client.py", line 177, in update_fact
    new_id =  self.conn.UpdateFactVerbatim(fact_id, dbus_fact)
  File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Python.sqlite3.OperationalError: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/dbus/service.py", line 711, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "src/hamster-service", line 176, in UpdateFactVerbatim
    return self.update_fact(fact_id, fact) or 0
  File "/home/clabaut/contrib/hamster/src/hamster/storage/storage.py", line 76, in update_fact
    self.__remove_fact(fact_id)
  File "/home/clabaut/contrib/hamster/src/hamster/storage/db.py", line 722, in __remove_fact
    self.__remove_index([fact_id])
  File "/home/clabaut/contrib/hamster/src/hamster/storage/db.py", line 819, in __remove_index
    self.execute("DELETE FROM fact_index where id in (%s)" % ids)
  File "/home/clabaut/contrib/hamster/src/hamster/storage/db.py", line 911, in execute
    cur.
  • Where hamster-service logs
hamster.storage.db - INFO - removing fact #dbus.Int32(8432)

The same problem occurs with release v2.2.2.

I guess a conversion from dbus data went wrong.

@matclab
Copy link
Author

matclab commented Nov 18, 2019

Note that python-dbus was upgraded from 1.2.10-1 to 1.2.12-1

@matclab
Copy link
Author

matclab commented Nov 18, 2019

Adding fact_id = int(fact_id) at the first line of __remove_fact function solves the problem.

(I tried to do the conversion in _dbfact_to_libfact, but it was not enough.

@ederag
Copy link
Collaborator

ederag commented Nov 18, 2019

Thanks for the report and the fix.

ids = ",".join((str(id) for id in ids))
logger.info("removing fact #{} from index".format(ids))
self.execute("DELETE FROM fact_index where id in (%s)" % ids)

Did python-dbus drop the __str__ overload for dbus.Int32 ?

Would be nice to report upstream, but where is the development page ?

For anyone interested, the 1.2.12 version refers to dbus-python.
https://pypi.org/project/dbus-python/1.2.12/
That has nothing to do with the dbus interface given on the dbus site
https://www.freedesktop.org/wiki/Software/DBusBindings/#python
(which is the homepage given on the dbus-python pypi page above)

@ederag
Copy link
Collaborator

ederag commented Nov 19, 2019

Found the dbus-python repo at the bottom of the previous page:
https://gitlab.freedesktop.org/dbus/dbus-python

The __str__ is inherited from builtins.int here.
What is the ouput of

python3 -c 'import dbus; print(dbus.Int32.__str__)'

on your system ?
Here (1.2.4) it gives <slot wrapper '__str__' of 'int' objects>.

And

python3 -c 'import dbus; print(str(dbus.Int32(34)))'

Here that prints 34.

And to rule out a python int issue,

python3 -c 'import dbus; print(str(int(34)))'

@matclab
Copy link
Author

matclab commented Nov 19, 2019

Here are the results:

python3 -c 'import dbus; print(dbus.Int32.__str__)'; python3 -c 'import dbus; print(str(dbus.Int32(34)))';  python3 -c 'import dbus; print(str(int(34)))'
<slot wrapper '__str__' of 'object' objects>
dbus.Int32(34)
34

So, there seems to have been a change in dbus.Int32__str__.
I've checked python3.8 changelog, but I didn't see anything that seems closely related.

@matclab
Copy link
Author

matclab commented Nov 19, 2019

I tried to open a bug report in https://gitlab.freedesktop.org, but I was unable to open an account. i'll try again later in the day.

@matclab
Copy link
Author

matclab commented Nov 19, 2019

Issue 31 opened upstream.

@matclab
Copy link
Author

matclab commented Nov 25, 2019

Upstream issue is closed with a fix (tested locally with hamster). I guess we can close this issue.

@GeraldJansen
Copy link
Contributor

Hmm, other Hamster users may be hit with this. For example, debian testing has python3.8 and python3-dbus-1.2.12. It may be better to either leave this open or integrate the work-around into hamster.

@ederag
Copy link
Collaborator

ederag commented Nov 26, 2019

dbus-python-1.2.14 has been tagged.
So this is fixed upstream (nice reactivity from the dbus-python devs),
and should be quickly incorporated into these leading edge distributions.
(would this assumption be wrong,
a PR with the workaround together with an inline comment pointing to the upstream issue
would be acceptable)

No strong objection to follow your advice and keep this issue open for a little while though,
since it is easy to forget to search into closed issues as well.

Thanks @matclab for the exemplary report, investigation and part of the quick upstream fix !

@matclab
Copy link
Author

matclab commented Nov 26, 2019

Thanks @ederag, both hamster and dbus-python community was very supportive. I'd like to take more time to help improve hamster has it is my daily driver, but time flies too fast !

@ederag
Copy link
Collaborator

ederag commented Jan 26, 2020

debian testing has 1.2.16 now
(1.2.14 was tagged two months ago), so it seems be safe to close.

@matclab

I'd like to take more time to help improve hamster

You already did. Quality feedback is precious, so testing PRs every now and then,
or just following the master branch would also be great.

@ederag ederag closed this as completed Jan 26, 2020
@ederag ederag mentioned this issue Mar 1, 2020
romanofski added a commit to romanofski/nixpkgs that referenced this issue Jul 20, 2020
This upgrades dbus-python to the 1.2.16 release. Reason for this version
upgrade is a the failing hamster application (see. programs.hamster).
With a 1.2.12 dbus-python version hamster can not start and fails with:

    Traceback (most recent call last):
      File "/nix/store/5ax21lyiprc9v5l3pl7dbfr2hqbrh970-hamster-3.0.2/bin/.hamster-wrapped", line 41, in <module>
        from hamster import client, reports
      File "/nix/store/5ax21lyiprc9v5l3pl7dbfr2hqbrh970-hamster-3.0.2/lib/python3.8/site-packages/hamster/client.py", line 46, in <module>
        assert not (
    AssertionError: python3.8 changed str(<dbus integers>).
       That broke hamster (projecthamster/hamster#477).
       Please upgrade to dbus-python >= 1.2.14.
FRidh pushed a commit to NixOS/nixpkgs that referenced this issue Jul 22, 2020
This upgrades dbus-python to the 1.2.16 release. Reason for this version
upgrade is a the failing hamster application (see. programs.hamster).
With a 1.2.12 dbus-python version hamster can not start and fails with:

    Traceback (most recent call last):
      File "/nix/store/5ax21lyiprc9v5l3pl7dbfr2hqbrh970-hamster-3.0.2/bin/.hamster-wrapped", line 41, in <module>
        from hamster import client, reports
      File "/nix/store/5ax21lyiprc9v5l3pl7dbfr2hqbrh970-hamster-3.0.2/lib/python3.8/site-packages/hamster/client.py", line 46, in <module>
        assert not (
    AssertionError: python3.8 changed str(<dbus integers>).
       That broke hamster (projecthamster/hamster#477).
       Please upgrade to dbus-python >= 1.2.14.
@acheype

This comment has been minimized.

@acheype

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants