From 4d2dff76fc25ad2ee7a18bbaeb334442329b6127 Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Thu, 29 Jan 2026 14:43:57 -0500 Subject: [PATCH] Updates stubs to accept the 'primary' argument. Catches TypeError for unsupported platforms and falls back to standard clipboard. --- src/pyperclip/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pyperclip/__init__.py b/src/pyperclip/__init__.py index 38999b3..a2f52c7 100644 --- a/src/pyperclip/__init__.py +++ b/src/pyperclip/__init__.py @@ -600,7 +600,7 @@ def set_clipboard(clipboard): copy, paste = clipboard_types[clipboard]() -def lazy_load_stub_copy(text): +def lazy_load_stub_copy(text, primary=False): ''' A stub function for copy(), which will load the real copy() function when called so that the real copy() function is used for later calls. @@ -619,10 +619,13 @@ def lazy_load_stub_copy(text): ''' global copy, paste copy, paste = determine_clipboard() - return copy(text) + try: + return copy(text, primary=primary) + except TypeError: + return copy(text) -def lazy_load_stub_paste(): +def lazy_load_stub_paste(primary=False): ''' A stub function for paste(), which will load the real paste() function when called so that the real paste() function is used for later calls. @@ -641,7 +644,10 @@ def lazy_load_stub_paste(): ''' global copy, paste copy, paste = determine_clipboard() - return paste() + try: + return paste(primary=primary) + except TypeError: + return paste() def is_available():