__init__.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. """
  2. Pyperclip
  3. A cross-platform clipboard module for Python,
  4. with copy & paste functions for plain text.
  5. By Al Sweigart al@inventwithpython.com
  6. BSD License
  7. Usage:
  8. import pyperclip
  9. pyperclip.copy('The text to be copied to the clipboard.')
  10. spam = pyperclip.paste()
  11. if not pyperclip.is_available():
  12. print("Copy functionality unavailable!")
  13. On Windows, no additional modules are needed.
  14. On Mac, the pyobjc module is used, falling back to the pbcopy and pbpaste cli
  15. commands. (These commands should come with OS X.).
  16. On Linux, install xclip or xsel via package manager. For example, in Debian:
  17. sudo apt-get install xclip
  18. sudo apt-get install xsel
  19. Otherwise on Linux, you will need the PyQt5 modules installed.
  20. This module does not work with PyGObject yet.
  21. Cygwin is currently not supported.
  22. Security Note: This module runs programs with these names:
  23. - which
  24. - where
  25. - pbcopy
  26. - pbpaste
  27. - xclip
  28. - xsel
  29. - klipper
  30. - qdbus
  31. A malicious user could rename or add programs with these names, tricking
  32. Pyperclip into running them with whatever permissions the Python process has.
  33. """
  34. __version__ = "1.7.0"
  35. import contextlib
  36. import ctypes
  37. from ctypes import (
  38. c_size_t,
  39. c_wchar,
  40. c_wchar_p,
  41. get_errno,
  42. sizeof,
  43. )
  44. import os
  45. import platform
  46. from shutil import which
  47. import subprocess
  48. import time
  49. import warnings
  50. from pandas.errors import (
  51. PyperclipException,
  52. PyperclipWindowsException,
  53. )
  54. from pandas.util._exceptions import find_stack_level
  55. # `import PyQt4` sys.exit()s if DISPLAY is not in the environment.
  56. # Thus, we need to detect the presence of $DISPLAY manually
  57. # and not load PyQt4 if it is absent.
  58. HAS_DISPLAY = os.getenv("DISPLAY")
  59. EXCEPT_MSG = """
  60. Pyperclip could not find a copy/paste mechanism for your system.
  61. For more information, please visit
  62. https://pyperclip.readthedocs.io/en/latest/#not-implemented-error
  63. """
  64. ENCODING = "utf-8"
  65. # The "which" unix command finds where a command is.
  66. if platform.system() == "Windows":
  67. WHICH_CMD = "where"
  68. else:
  69. WHICH_CMD = "which"
  70. def _executable_exists(name):
  71. return (
  72. subprocess.call(
  73. [WHICH_CMD, name], stdout=subprocess.PIPE, stderr=subprocess.PIPE
  74. )
  75. == 0
  76. )
  77. def _stringifyText(text) -> str:
  78. acceptedTypes = (str, int, float, bool)
  79. if not isinstance(text, acceptedTypes):
  80. raise PyperclipException(
  81. f"only str, int, float, and bool values "
  82. f"can be copied to the clipboard, not {type(text).__name__}"
  83. )
  84. return str(text)
  85. def init_osx_pbcopy_clipboard():
  86. def copy_osx_pbcopy(text):
  87. text = _stringifyText(text) # Converts non-str values to str.
  88. with subprocess.Popen(
  89. ["pbcopy", "w"], stdin=subprocess.PIPE, close_fds=True
  90. ) as p:
  91. p.communicate(input=text.encode(ENCODING))
  92. def paste_osx_pbcopy():
  93. with subprocess.Popen(
  94. ["pbpaste", "r"], stdout=subprocess.PIPE, close_fds=True
  95. ) as p:
  96. stdout = p.communicate()[0]
  97. return stdout.decode(ENCODING)
  98. return copy_osx_pbcopy, paste_osx_pbcopy
  99. def init_osx_pyobjc_clipboard():
  100. def copy_osx_pyobjc(text):
  101. """Copy string argument to clipboard"""
  102. text = _stringifyText(text) # Converts non-str values to str.
  103. newStr = Foundation.NSString.stringWithString_(text).nsstring()
  104. newData = newStr.dataUsingEncoding_(Foundation.NSUTF8StringEncoding)
  105. board = AppKit.NSPasteboard.generalPasteboard()
  106. board.declareTypes_owner_([AppKit.NSStringPboardType], None)
  107. board.setData_forType_(newData, AppKit.NSStringPboardType)
  108. def paste_osx_pyobjc():
  109. """Returns contents of clipboard"""
  110. board = AppKit.NSPasteboard.generalPasteboard()
  111. content = board.stringForType_(AppKit.NSStringPboardType)
  112. return content
  113. return copy_osx_pyobjc, paste_osx_pyobjc
  114. def init_qt_clipboard():
  115. global QApplication
  116. # $DISPLAY should exist
  117. # Try to import from qtpy, but if that fails try PyQt5 then PyQt4
  118. try:
  119. from qtpy.QtWidgets import QApplication
  120. except ImportError:
  121. try:
  122. from PyQt5.QtWidgets import QApplication
  123. except ImportError:
  124. from PyQt4.QtGui import QApplication
  125. app = QApplication.instance()
  126. if app is None:
  127. app = QApplication([])
  128. def copy_qt(text):
  129. text = _stringifyText(text) # Converts non-str values to str.
  130. cb = app.clipboard()
  131. cb.setText(text)
  132. def paste_qt() -> str:
  133. cb = app.clipboard()
  134. return str(cb.text())
  135. return copy_qt, paste_qt
  136. def init_xclip_clipboard():
  137. DEFAULT_SELECTION = "c"
  138. PRIMARY_SELECTION = "p"
  139. def copy_xclip(text, primary=False):
  140. text = _stringifyText(text) # Converts non-str values to str.
  141. selection = DEFAULT_SELECTION
  142. if primary:
  143. selection = PRIMARY_SELECTION
  144. with subprocess.Popen(
  145. ["xclip", "-selection", selection], stdin=subprocess.PIPE, close_fds=True
  146. ) as p:
  147. p.communicate(input=text.encode(ENCODING))
  148. def paste_xclip(primary=False):
  149. selection = DEFAULT_SELECTION
  150. if primary:
  151. selection = PRIMARY_SELECTION
  152. with subprocess.Popen(
  153. ["xclip", "-selection", selection, "-o"],
  154. stdout=subprocess.PIPE,
  155. stderr=subprocess.PIPE,
  156. close_fds=True,
  157. ) as p:
  158. stdout = p.communicate()[0]
  159. # Intentionally ignore extraneous output on stderr when clipboard is empty
  160. return stdout.decode(ENCODING)
  161. return copy_xclip, paste_xclip
  162. def init_xsel_clipboard():
  163. DEFAULT_SELECTION = "-b"
  164. PRIMARY_SELECTION = "-p"
  165. def copy_xsel(text, primary=False):
  166. text = _stringifyText(text) # Converts non-str values to str.
  167. selection_flag = DEFAULT_SELECTION
  168. if primary:
  169. selection_flag = PRIMARY_SELECTION
  170. with subprocess.Popen(
  171. ["xsel", selection_flag, "-i"], stdin=subprocess.PIPE, close_fds=True
  172. ) as p:
  173. p.communicate(input=text.encode(ENCODING))
  174. def paste_xsel(primary=False):
  175. selection_flag = DEFAULT_SELECTION
  176. if primary:
  177. selection_flag = PRIMARY_SELECTION
  178. with subprocess.Popen(
  179. ["xsel", selection_flag, "-o"], stdout=subprocess.PIPE, close_fds=True
  180. ) as p:
  181. stdout = p.communicate()[0]
  182. return stdout.decode(ENCODING)
  183. return copy_xsel, paste_xsel
  184. def init_klipper_clipboard():
  185. def copy_klipper(text):
  186. text = _stringifyText(text) # Converts non-str values to str.
  187. with subprocess.Popen(
  188. [
  189. "qdbus",
  190. "org.kde.klipper",
  191. "/klipper",
  192. "setClipboardContents",
  193. text.encode(ENCODING),
  194. ],
  195. stdin=subprocess.PIPE,
  196. close_fds=True,
  197. ) as p:
  198. p.communicate(input=None)
  199. def paste_klipper():
  200. with subprocess.Popen(
  201. ["qdbus", "org.kde.klipper", "/klipper", "getClipboardContents"],
  202. stdout=subprocess.PIPE,
  203. close_fds=True,
  204. ) as p:
  205. stdout = p.communicate()[0]
  206. # Workaround for https://bugs.kde.org/show_bug.cgi?id=342874
  207. # TODO: https://github.com/asweigart/pyperclip/issues/43
  208. clipboardContents = stdout.decode(ENCODING)
  209. # even if blank, Klipper will append a newline at the end
  210. assert len(clipboardContents) > 0
  211. # make sure that newline is there
  212. assert clipboardContents.endswith("\n")
  213. if clipboardContents.endswith("\n"):
  214. clipboardContents = clipboardContents[:-1]
  215. return clipboardContents
  216. return copy_klipper, paste_klipper
  217. def init_dev_clipboard_clipboard():
  218. def copy_dev_clipboard(text):
  219. text = _stringifyText(text) # Converts non-str values to str.
  220. if text == "":
  221. warnings.warn(
  222. "Pyperclip cannot copy a blank string to the clipboard on Cygwin. "
  223. "This is effectively a no-op.",
  224. stacklevel=find_stack_level(),
  225. )
  226. if "\r" in text:
  227. warnings.warn(
  228. "Pyperclip cannot handle \\r characters on Cygwin.",
  229. stacklevel=find_stack_level(),
  230. )
  231. with open("/dev/clipboard", "w") as fd:
  232. fd.write(text)
  233. def paste_dev_clipboard() -> str:
  234. with open("/dev/clipboard") as fd:
  235. content = fd.read()
  236. return content
  237. return copy_dev_clipboard, paste_dev_clipboard
  238. def init_no_clipboard():
  239. class ClipboardUnavailable:
  240. def __call__(self, *args, **kwargs):
  241. raise PyperclipException(EXCEPT_MSG)
  242. def __bool__(self) -> bool:
  243. return False
  244. return ClipboardUnavailable(), ClipboardUnavailable()
  245. # Windows-related clipboard functions:
  246. class CheckedCall:
  247. def __init__(self, f) -> None:
  248. super().__setattr__("f", f)
  249. def __call__(self, *args):
  250. ret = self.f(*args)
  251. if not ret and get_errno():
  252. raise PyperclipWindowsException("Error calling " + self.f.__name__)
  253. return ret
  254. def __setattr__(self, key, value):
  255. setattr(self.f, key, value)
  256. def init_windows_clipboard():
  257. global HGLOBAL, LPVOID, DWORD, LPCSTR, INT
  258. global HWND, HINSTANCE, HMENU, BOOL, UINT, HANDLE
  259. from ctypes.wintypes import (
  260. BOOL,
  261. DWORD,
  262. HANDLE,
  263. HGLOBAL,
  264. HINSTANCE,
  265. HMENU,
  266. HWND,
  267. INT,
  268. LPCSTR,
  269. LPVOID,
  270. UINT,
  271. )
  272. windll = ctypes.windll
  273. msvcrt = ctypes.CDLL("msvcrt")
  274. safeCreateWindowExA = CheckedCall(windll.user32.CreateWindowExA)
  275. safeCreateWindowExA.argtypes = [
  276. DWORD,
  277. LPCSTR,
  278. LPCSTR,
  279. DWORD,
  280. INT,
  281. INT,
  282. INT,
  283. INT,
  284. HWND,
  285. HMENU,
  286. HINSTANCE,
  287. LPVOID,
  288. ]
  289. safeCreateWindowExA.restype = HWND
  290. safeDestroyWindow = CheckedCall(windll.user32.DestroyWindow)
  291. safeDestroyWindow.argtypes = [HWND]
  292. safeDestroyWindow.restype = BOOL
  293. OpenClipboard = windll.user32.OpenClipboard
  294. OpenClipboard.argtypes = [HWND]
  295. OpenClipboard.restype = BOOL
  296. safeCloseClipboard = CheckedCall(windll.user32.CloseClipboard)
  297. safeCloseClipboard.argtypes = []
  298. safeCloseClipboard.restype = BOOL
  299. safeEmptyClipboard = CheckedCall(windll.user32.EmptyClipboard)
  300. safeEmptyClipboard.argtypes = []
  301. safeEmptyClipboard.restype = BOOL
  302. safeGetClipboardData = CheckedCall(windll.user32.GetClipboardData)
  303. safeGetClipboardData.argtypes = [UINT]
  304. safeGetClipboardData.restype = HANDLE
  305. safeSetClipboardData = CheckedCall(windll.user32.SetClipboardData)
  306. safeSetClipboardData.argtypes = [UINT, HANDLE]
  307. safeSetClipboardData.restype = HANDLE
  308. safeGlobalAlloc = CheckedCall(windll.kernel32.GlobalAlloc)
  309. safeGlobalAlloc.argtypes = [UINT, c_size_t]
  310. safeGlobalAlloc.restype = HGLOBAL
  311. safeGlobalLock = CheckedCall(windll.kernel32.GlobalLock)
  312. safeGlobalLock.argtypes = [HGLOBAL]
  313. safeGlobalLock.restype = LPVOID
  314. safeGlobalUnlock = CheckedCall(windll.kernel32.GlobalUnlock)
  315. safeGlobalUnlock.argtypes = [HGLOBAL]
  316. safeGlobalUnlock.restype = BOOL
  317. wcslen = CheckedCall(msvcrt.wcslen)
  318. wcslen.argtypes = [c_wchar_p]
  319. wcslen.restype = UINT
  320. GMEM_MOVEABLE = 0x0002
  321. CF_UNICODETEXT = 13
  322. @contextlib.contextmanager
  323. def window():
  324. """
  325. Context that provides a valid Windows hwnd.
  326. """
  327. # we really just need the hwnd, so setting "STATIC"
  328. # as predefined lpClass is just fine.
  329. hwnd = safeCreateWindowExA(
  330. 0, b"STATIC", None, 0, 0, 0, 0, 0, None, None, None, None
  331. )
  332. try:
  333. yield hwnd
  334. finally:
  335. safeDestroyWindow(hwnd)
  336. @contextlib.contextmanager
  337. def clipboard(hwnd):
  338. """
  339. Context manager that opens the clipboard and prevents
  340. other applications from modifying the clipboard content.
  341. """
  342. # We may not get the clipboard handle immediately because
  343. # some other application is accessing it (?)
  344. # We try for at least 500ms to get the clipboard.
  345. t = time.time() + 0.5
  346. success = False
  347. while time.time() < t:
  348. success = OpenClipboard(hwnd)
  349. if success:
  350. break
  351. time.sleep(0.01)
  352. if not success:
  353. raise PyperclipWindowsException("Error calling OpenClipboard")
  354. try:
  355. yield
  356. finally:
  357. safeCloseClipboard()
  358. def copy_windows(text):
  359. # This function is heavily based on
  360. # http://msdn.com/ms649016#_win32_Copying_Information_to_the_Clipboard
  361. text = _stringifyText(text) # Converts non-str values to str.
  362. with window() as hwnd:
  363. # http://msdn.com/ms649048
  364. # If an application calls OpenClipboard with hwnd set to NULL,
  365. # EmptyClipboard sets the clipboard owner to NULL;
  366. # this causes SetClipboardData to fail.
  367. # => We need a valid hwnd to copy something.
  368. with clipboard(hwnd):
  369. safeEmptyClipboard()
  370. if text:
  371. # http://msdn.com/ms649051
  372. # If the hMem parameter identifies a memory object,
  373. # the object must have been allocated using the
  374. # function with the GMEM_MOVEABLE flag.
  375. count = wcslen(text) + 1
  376. handle = safeGlobalAlloc(GMEM_MOVEABLE, count * sizeof(c_wchar))
  377. locked_handle = safeGlobalLock(handle)
  378. ctypes.memmove(
  379. c_wchar_p(locked_handle),
  380. c_wchar_p(text),
  381. count * sizeof(c_wchar),
  382. )
  383. safeGlobalUnlock(handle)
  384. safeSetClipboardData(CF_UNICODETEXT, handle)
  385. def paste_windows():
  386. with clipboard(None):
  387. handle = safeGetClipboardData(CF_UNICODETEXT)
  388. if not handle:
  389. # GetClipboardData may return NULL with errno == NO_ERROR
  390. # if the clipboard is empty.
  391. # (Also, it may return a handle to an empty buffer,
  392. # but technically that's not empty)
  393. return ""
  394. return c_wchar_p(handle).value
  395. return copy_windows, paste_windows
  396. def init_wsl_clipboard():
  397. def copy_wsl(text):
  398. text = _stringifyText(text) # Converts non-str values to str.
  399. with subprocess.Popen(["clip.exe"], stdin=subprocess.PIPE, close_fds=True) as p:
  400. p.communicate(input=text.encode(ENCODING))
  401. def paste_wsl():
  402. with subprocess.Popen(
  403. ["powershell.exe", "-command", "Get-Clipboard"],
  404. stdout=subprocess.PIPE,
  405. stderr=subprocess.PIPE,
  406. close_fds=True,
  407. ) as p:
  408. stdout = p.communicate()[0]
  409. # WSL appends "\r\n" to the contents.
  410. return stdout[:-2].decode(ENCODING)
  411. return copy_wsl, paste_wsl
  412. # Automatic detection of clipboard mechanisms
  413. # and importing is done in determine_clipboard():
  414. def determine_clipboard():
  415. """
  416. Determine the OS/platform and set the copy() and paste() functions
  417. accordingly.
  418. """
  419. global Foundation, AppKit, qtpy, PyQt4, PyQt5
  420. # Setup for the CYGWIN platform:
  421. if (
  422. "cygwin" in platform.system().lower()
  423. ): # Cygwin has a variety of values returned by platform.system(),
  424. # such as 'CYGWIN_NT-6.1'
  425. # FIXME(pyperclip#55): pyperclip currently does not support Cygwin,
  426. # see https://github.com/asweigart/pyperclip/issues/55
  427. if os.path.exists("/dev/clipboard"):
  428. warnings.warn(
  429. "Pyperclip's support for Cygwin is not perfect, "
  430. "see https://github.com/asweigart/pyperclip/issues/55",
  431. stacklevel=find_stack_level(),
  432. )
  433. return init_dev_clipboard_clipboard()
  434. # Setup for the WINDOWS platform:
  435. elif os.name == "nt" or platform.system() == "Windows":
  436. return init_windows_clipboard()
  437. if platform.system() == "Linux":
  438. if which("wslconfig.exe"):
  439. return init_wsl_clipboard()
  440. # Setup for the macOS platform:
  441. if os.name == "mac" or platform.system() == "Darwin":
  442. try:
  443. import AppKit
  444. import Foundation # check if pyobjc is installed
  445. except ImportError:
  446. return init_osx_pbcopy_clipboard()
  447. else:
  448. return init_osx_pyobjc_clipboard()
  449. # Setup for the LINUX platform:
  450. if HAS_DISPLAY:
  451. if _executable_exists("xsel"):
  452. return init_xsel_clipboard()
  453. if _executable_exists("xclip"):
  454. return init_xclip_clipboard()
  455. if _executable_exists("klipper") and _executable_exists("qdbus"):
  456. return init_klipper_clipboard()
  457. try:
  458. # qtpy is a small abstraction layer that lets you write applications
  459. # using a single api call to either PyQt or PySide.
  460. # https://pypi.python.org/project/QtPy
  461. import qtpy # check if qtpy is installed
  462. except ImportError:
  463. # If qtpy isn't installed, fall back on importing PyQt4.
  464. try:
  465. import PyQt5 # check if PyQt5 is installed
  466. except ImportError:
  467. try:
  468. import PyQt4 # check if PyQt4 is installed
  469. except ImportError:
  470. pass # We want to fail fast for all non-ImportError exceptions.
  471. else:
  472. return init_qt_clipboard()
  473. else:
  474. return init_qt_clipboard()
  475. else:
  476. return init_qt_clipboard()
  477. return init_no_clipboard()
  478. def set_clipboard(clipboard):
  479. """
  480. Explicitly sets the clipboard mechanism. The "clipboard mechanism" is how
  481. the copy() and paste() functions interact with the operating system to
  482. implement the copy/paste feature. The clipboard parameter must be one of:
  483. - pbcopy
  484. - pyobjc (default on macOS)
  485. - qt
  486. - xclip
  487. - xsel
  488. - klipper
  489. - windows (default on Windows)
  490. - no (this is what is set when no clipboard mechanism can be found)
  491. """
  492. global copy, paste
  493. clipboard_types = {
  494. "pbcopy": init_osx_pbcopy_clipboard,
  495. "pyobjc": init_osx_pyobjc_clipboard,
  496. "qt": init_qt_clipboard, # TODO - split this into 'qtpy', 'pyqt4', and 'pyqt5'
  497. "xclip": init_xclip_clipboard,
  498. "xsel": init_xsel_clipboard,
  499. "klipper": init_klipper_clipboard,
  500. "windows": init_windows_clipboard,
  501. "no": init_no_clipboard,
  502. }
  503. if clipboard not in clipboard_types:
  504. allowed_clipboard_types = [repr(_) for _ in clipboard_types]
  505. raise ValueError(
  506. f"Argument must be one of {', '.join(allowed_clipboard_types)}"
  507. )
  508. # Sets pyperclip's copy() and paste() functions:
  509. copy, paste = clipboard_types[clipboard]()
  510. def lazy_load_stub_copy(text):
  511. """
  512. A stub function for copy(), which will load the real copy() function when
  513. called so that the real copy() function is used for later calls.
  514. This allows users to import pyperclip without having determine_clipboard()
  515. automatically run, which will automatically select a clipboard mechanism.
  516. This could be a problem if it selects, say, the memory-heavy PyQt4 module
  517. but the user was just going to immediately call set_clipboard() to use a
  518. different clipboard mechanism.
  519. The lazy loading this stub function implements gives the user a chance to
  520. call set_clipboard() to pick another clipboard mechanism. Or, if the user
  521. simply calls copy() or paste() without calling set_clipboard() first,
  522. will fall back on whatever clipboard mechanism that determine_clipboard()
  523. automatically chooses.
  524. """
  525. global copy, paste
  526. copy, paste = determine_clipboard()
  527. return copy(text)
  528. def lazy_load_stub_paste():
  529. """
  530. A stub function for paste(), which will load the real paste() function when
  531. called so that the real paste() function is used for later calls.
  532. This allows users to import pyperclip without having determine_clipboard()
  533. automatically run, which will automatically select a clipboard mechanism.
  534. This could be a problem if it selects, say, the memory-heavy PyQt4 module
  535. but the user was just going to immediately call set_clipboard() to use a
  536. different clipboard mechanism.
  537. The lazy loading this stub function implements gives the user a chance to
  538. call set_clipboard() to pick another clipboard mechanism. Or, if the user
  539. simply calls copy() or paste() without calling set_clipboard() first,
  540. will fall back on whatever clipboard mechanism that determine_clipboard()
  541. automatically chooses.
  542. """
  543. global copy, paste
  544. copy, paste = determine_clipboard()
  545. return paste()
  546. def is_available() -> bool:
  547. return copy != lazy_load_stub_copy and paste != lazy_load_stub_paste
  548. # Initially, copy() and paste() are set to lazy loading wrappers which will
  549. # set `copy` and `paste` to real functions the first time they're used, unless
  550. # set_clipboard() or determine_clipboard() is called first.
  551. copy, paste = lazy_load_stub_copy, lazy_load_stub_paste
  552. __all__ = ["copy", "paste", "set_clipboard", "determine_clipboard"]
  553. # pandas aliases
  554. clipboard_get = paste
  555. clipboard_set = copy