Skip to content

fix: macOS compatibility - handle missing BlueZ import#87

Merged
rbaron merged 1 commit into
rbaron:mainfrom
b1nmar:main
May 26, 2026
Merged

fix: macOS compatibility - handle missing BlueZ import#87
rbaron merged 1 commit into
rbaron:mainfrom
b1nmar:main

Conversation

@b1nmar

@b1nmar b1nmar commented May 25, 2026

Copy link
Copy Markdown

Problem

On macOS, BleakClientBlueZDBus from bleak.backends.bluezdbus.client is not available — BlueZ is Linux-only. This caused an ImportError when running catprinter on macOS.

Solution

  • Wrap the BleakClientBlueZDBus import in a try/except ImportError block, setting it to None when unavailable.
  • Guard the isinstance check with BleakClientBlueZDBus and ... so the manual MTU negotiation only runs on Linux (where BlueZ is present).

This makes the code fully compatible with both Linux and macOS with no behavior change on Linux.

Testing

Tested successfully on macOS with a GB01/GB02 cat printer.

BlueZ is Linux-only. On macOS, importing BleakClientBlueZDBus raises
ImportError. Wrap the import in a try/except and guard the isinstance
check so the printer works on both Linux and macOS.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rbaron

rbaron commented May 26, 2026

Copy link
Copy Markdown
Owner

Thanks @b1nmar.

@rbaron rbaron merged commit 20fe5b7 into rbaron:main May 26, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants