asweigart / pyperclip

Python module for cross-platform clipboard functions.
https://pypi.python.org/pypi/pyperclip
BSD 3-Clause "New" or "Revised" License
1.65k stars 196 forks source link

pyperclip induces strange shell behavior #228

Open ryneches opened 2 years ago

ryneches commented 2 years ago

Invoking pyperclip.copy() inside a script breaks the script's STDOUT redirection on the command line.

Create a file called copy.py :

#!/usr/bin/env python

import pyperclip
pyperclip.copy( 'hello world!' )
print( 'foo' )

Run the script from the terminal :

$ ./copy.py
foo
$

The paste buffer now contains the text "hello world!" However, if you try to capture STDOUT, the script hangs :

$ ./copy.py | grep bar
<<hangs>>
zhaowb commented 1 year ago

@ryneches I tried in a fresh virtualenv, can't repeat the problem. Versions tried: 3.7.13, 3.8.13, 3.9.13, 3.10.4, with pyenv. macOS 13.0.1 GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin19.4.0)