python-editor icon indicating copy to clipboard operation
python-editor copied to clipboard

PermissionError: [Errno 13] on Windows 10

Open maxfire2008 opened this issue 2 years ago • 1 comments

On Windows I get an error. This is because tmp = tempfile.NamedTemporaryFile(suffix=suffix) (line 84) opens and locks the file. This can be fixed by calling tmp.close() directly afterwards but I don't know if this breaks anything on other OSes.

>>> editor.edit(contents="hello")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Max\AppData\Local\pypoetry\Cache\virtualenvs\bulletin-3-N3PFQvT7-py3.10\lib\site-packages\editor.py", line 92, in edit
    with open(filename, mode='wb') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Max\\AppData\\Local\\Temp\\tmp55cimtei'

maxfire2008 avatar Apr 01 '23 03:04 maxfire2008

Can confirm fixes the problem.

thomaspj10 avatar Dec 13 '24 21:12 thomaspj10