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

Fail early in case problems with GObject import #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fail early in case problems with GObject import #182

wants to merge 1 commit into from

Conversation

dynobo
Copy link

@dynobo dynobo commented Nov 3, 2020

Hi,

this PR fixes an issue, where pyperclip selects gtk-clipboard even if it's not really working, and then fails with an exception later (see below).

This problem occurred, when I used pyperclip together with pystray. It seems they both use conflicting ways to import GObjects. A simple call gtk.Clipboard() can detect that and pyperclip can switch to an alternative clipboard handler.

Thanks!

[...]
  File "/home/holger/coding/normcap/normcap/handlers/clipboard_handler.py", line 23, in handle
    pyperclip.copy(request.transformed)
  File "/home/holger/coding/normcap/.venv/lib/python3.8/site-packages/pyperclip/__init__.py", line 721, in lazy_load_stub_copy
    return copy(text)
  File "/home/holger/coding/normcap/.venv/lib/python3.8/site-packages/pyperclip/__init__.py", line 166, in copy_gtk
    cb = gtk.Clipboard()
  File "/home/holger/coding/normcap/.venv/lib/python3.8/site-packages/gi/__init__.py", line 69, in __getattr__
    raise AttributeError(_static_binding_error)
AttributeError: When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject". See: https://bugzilla.gnome.org/show_bug.cgi?id=709183

@snowman2
Copy link

Related #225

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