• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spesmilo / electrum / 4917020841476096
61%
master: 63%

Build:
Build:
LAST BUILD BRANCH: levelDB
DEFAULT BRANCH: master
Ran 19 Mar 2025 04:35PM UTC
Jobs 5
Files 81
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

19 Mar 2025 04:27PM UTC coverage: 61.11% (-0.005%) from 61.115%
4917020841476096

Pull #9655

CirrusCI

SomberNight
plugins: better handle exceptions in __init__

When importing a plugin, if it raised an exception in its `__init__` file, we
ignored it, and still loaded the plugin, in a potentially half-broken state.
This is because maybe_load_plugin_init_method only calls exec_module_from_spec
if the plugin is not already in sys.modules, but exec_module_from_spec
will put the plugin into sys.modules even if it errors.

Consider this patch to test with, enable the "labels" plugin:
```patch
diff --git a/electrum/plugins/labels/__init__.py b/electrum/plugins/labels/__init__.py
index b68127df8e..0d6d95abce 100644
--- a/electrum/plugins/labels/__init__.py
+++ b/electrum/plugins/labels/__init__.py
@@ -21,3 +21,5 @@ async def pull(self: 'Commands', plugin: 'LabelsPlugin' = None, wallet=None, for
     arg:bool:force:pull all labels
     """
     return await plugin.pull_thread(wallet, force=force)
+
+raise Exception("heyheyhey")

```

I would expect we don't load the labels plugin due to the error, but we do:
```
>>> plugins.get_plugin("labels")
<electrum.plugins.labels.qt.Plugin object at 0x7801df30fb50>
```

Log:
```
$ ./run_electrum -v --testnet -o
  0.75 | I | simple_config.SimpleConfig | electrum directory /home/user/.electrum/testnet
  0.75 | E | p/plugin.Plugins | cannot initialize plugin labels: Error pre-loading electrum.plugins.labels: Exception('heyheyhey')
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/plugin.py", line 148, in exec_module_from_spec
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/wspace/electrum/electrum/plugins/labels/__init__.py", line 25, in <module>
    raise Exception("heyheyhey")
Exception: heyheyhey

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/plu... (continued)
Pull Request #9655: plugins: better handle exceptions in `__init__`

3 of 7 new or added lines in 1 file covered. (42.86%)

2 existing lines in 2 files now uncovered.

21366 of 34963 relevant lines covered (61.11%)

3.05 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
4
41.09
-0.06% electrum/plugin.py

Uncovered Existing Lines

Lines Coverage ∆ File
1
80.24
-0.29% electrum/crypto.py
1
41.09
-0.06% electrum/plugin.py
Jobs
ID Job ID Ran Files Coverage
1 4917020841476096.1 19 Mar 2025 04:35PM UTC 81
61.07
2 4917020841476096.2 19 Mar 2025 04:35PM UTC 81
61.07
3 4917020841476096.3 19 Mar 2025 04:35PM UTC 81
61.08
4 4917020841476096.4 19 Mar 2025 04:35PM UTC 81
61.07
5 4917020841476096.5 19 Mar 2025 04:47PM UTC 81
61.04
Source Files on build 4917020841476096
  • Tree
  • List 81
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Build #49170208...
  • Pull Request #9655
  • PR Base - master (#47646342...)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc