-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Я использую:
I use:
- Windows 8.1 x64
- Python 3.8.1
- Far Manager 3.0.5596 x64 (as user or as Administrator - no matter)
Вот файл test.py, который падает с ошибкой:
Here is the file test.py that fails:
import descript.ion
with descript.ion.open('.\\test.py') as f:
f.description = 'Description 1'
# Файл 'descript.ion' создался и содержит описание test.py
# File 'descript.ion' created; it contains the description of test.py
with descript.ion.open('.\\test.py') as f:
f.description = 'Description 2'
# Traceback (most recent call last):
# File "D:\V\Programs\Python\description\test.py", line 8, in <module>
# f.description = 'Description 2'
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 97, in __set__
# self[obj.name] = val
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 87, in __setitem__
# del self[key]
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 91, in __delitem__
# delete_key(key)
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 42, in wrapper
# return clbl(dfile, key, *args, **kwargs)
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 60, in delete_key
# copyfile(dst.name, dfile)
# File "C:\Program Files\Python\lib\shutil.py", line 259, in copyfile
# with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
# PermissionError: [Errno 13] Permission denied: 'C:\\TEMP\\tmp_o6x646l'Для отладки я добавил строку в ion.py:
I added debug line into ion.py:
input("Temporary file: "+dst.name)
# Здесь я проверил, что временный файл существует и доступен для чтения
# Here I checked that the temporary file exists and is readable
copyfile(dst.name, dfile)Возможно, проблема в этом:
This may be the reason of the problem:
https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile:
Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later).
Возможные изменения в функции delete_key(dfile, key)
Possible changes in function delete_key(dfile, key):
...
dst = tempfile.NamedTemporaryFile('w+', delete = False)
with native_open(dfile, 'r') as src:
...
dst.close()
copyfile(dst.name, dfile)
os.remove(dst.name)
...Metadata
Metadata
Assignees
Labels
No labels