[issue43292] xml.ElementTree iterparse filehandle left open

2021-02-21 Thread Viktor Kis


New submission from Viktor Kis :

Standard library xml.ElementTree - iterparse does not close filehandle properly 
when breaking out of a for loop iterating with iterparse. The issue only occurs 
when the user passes a "string" as a source object instead of a filehandle 
(that is because a user's filehandle can safely be closed in a context manager 
as shown in the attachment).

--
components: XML
files: ETiterparse.py
messages: 387494
nosy: vkisforever
priority: normal
severity: normal
status: open
title: xml.ElementTree iterparse filehandle left open
type: crash
versions: Python 3.9
Added file: https://bugs.python.org/file49826/ETiterparse.py

___
Python tracker 
<https://bugs.python.org/issue43292>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43292] xml.ElementTree iterparse filehandle left open

2021-02-21 Thread Viktor Kis


Viktor Kis  added the comment:

ran python 3.9.2 on windows 10

1) What did you do?
Tried to remove folder that contains a xml file that was worked on by 
ElementTree iterparse with argument source='filename' (string type input)
2. What happened?
python was not able to remove the folder due to file lock still held by 
iterparse.
3. What did you expect to happen
iterparse was supposed to close the filehandle such that the user could then 
write/move/delete the xml file worked on, however python gave a PermissionError:

Traceback (most recent call last):
  File 
"C:\Users\vkisf\Desktop\00_MYSTUFF\01_SOFTWARE\01_PYTHON\01_GITHUB\pycascades2021\ETiterparse.py",
 line 43, in 
shutil.rmtree('subdir2')
  File 
"C:\Users\vkisf\Desktop\00_MYSTUFF\01_SOFTWARE\01_PYTHON\01_GITHUB\pycascades2021\cpython\lib\shutil.py",
 line 740, in rmtree
return _rmtree_unsafe(path, onerror)
  File 
"C:\Users\vkisf\Desktop\00_MYSTUFF\01_SOFTWARE\01_PYTHON\01_GITHUB\pycascades2021\cpython\lib\shutil.py",
 line 618, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
  File 
"C:\Users\vkisf\Desktop\00_MYSTUFF\01_SOFTWARE\01_PYTHON\01_GITHUB\pycascades2021\cpython\lib\shutil.py",
 line 616, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process: 'subdir2\\app.xml'

--
nosy:  -anthonypjshaw

___
Python tracker 
<https://bugs.python.org/issue43292>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43292] xml.ElementTree iterparse filehandle left open

2021-02-21 Thread Viktor Kis


Viktor Kis  added the comment:

Confirmed that no apps were using the created xml file or folder. Windows 
Explorer was closed for all folders only the terminal shell was open. Issue 
still persists on windows 10 OS.

--

___
Python tracker 
<https://bugs.python.org/issue43292>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com