Skip to content

Issues related to *_by_func methods #126

@jhakonen

Description

@jhakonen

Hi,

This recent change is making handler_block_by_func to fail for me:
4c39360

I originally encountered this with Tsumiki and reported this in rubiin/Tsumiki#97, but it seems to not reproduce.

I'm getting this error from Tsumiki:

Traceback (most recent call last):
  File "/nix/store/31liyp8gv12nd5dp8wxs4w2cajx57vws-python3-3.13.4-env/lib/python3.13/site-packages/fabric/utils/helpers.py", line 875, in wrapper
    return func(*passed_args[:args_len])
  File "/nix/store/31liyp8gv12nd5dp8wxs4w2cajx57vws-python3-3.13.4-env/lib/python3.13/site-packages/fabric/utils/helpers.py", line 615, in wrapper
    result = func(*args, **kwargs)
  File "/home/jhakonen/code/Tsumiki/modules/osd.py", line 147, in update_volume
    speaker.handler_block_by_func(self.update_volume)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
TypeError: nothing connected to <bound method AudioOSDContainer.update_volume of <osd.AudioOSDContainer object at 0x7ffff567b380 (modules+osd+AudioOSDContainer at 0x1f352c0)>>

This seems to happen because connect call does not pass the original handler function anymore to the underlying GObject implementation, but instead the handler is a wrapper that is returned from make_arguments_ignorable.
When you then try block the handler like this:

obj.handler_block_by_func(original_handler)

It fails, because the original handler is not there.

I've attached a patch with a unit test that fails with HEAD of main in Fabric:

handler-block-regression.patch.txt

$ git clone https://github.com/Fabric-Development/fabric.git
$ cd fabric

# Checkout commit before the regression, this works fine
$ git checkout 4c39360^
...
HEAD is now at 49c00af feat: implement more overrides for `Service`

$ git apply /path/to/handler-block-regression.patch
$ nix develop --command bash -c "python3 tests/service.3.py"
............
----------------------------------------------------------------------
Ran 12 tests in 0.001s

OK

$ git checkout .

# Checkout main, or the failing 4c39360 commit, or any commit in between
$ git checkout main
$ git apply /path/to/handler-block-regression.patch
$ nix develop --command bash -c "python3 tests/service.3.py"
...........E...
======================================================================
ERROR: testServiceSignalsConnectAndEmit8 (__main__.TestServiceSignals.testServiceSignalsConnectAndEmit8)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jhakonen/code/fabric/tests/service.3.py", line 318, in testServiceSignalsConnectAndEmit8
    service.handler_block_by_func(handler)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: nothing connected to <function TestServiceSignals.testServiceSignalsConnectAndEmit8.<locals>.handler at 0x7ffff180d300>

----------------------------------------------------------------------
Ran 15 tests in 0.002s

FAILED (errors=1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions