Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when attempting to view dom.minidom.Element object in Variable Explorer #5642

Closed
greenorca opened this issue Nov 2, 2017 · 3 comments

Comments

@greenorca
Copy link

Description

variable explorers list view crashes on opening nested xml elements

What steps will reproduce the problem?

  1. extract content.xml from *.odt, load it into xml.dom.minidom object
  2. variable2View = dom.getElementsByTagName(...) becomes a dom.minicompat.NodeList
  3. open variable2View, and try to open one of the contained cells

What is the expected output? What do you see instead?
expected to see content of the xml node, got a crash instead

Please provide any additional information below

File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 513, in createEditor
readonly=readonly)
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 1308, in setup
readonly=readonly, remote=remote)
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 1260, in init
title)
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 1145, in init
minmax=minmax)
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 110, in init
self.set_data(data)
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 158, in set_data
self.set_size_and_type()
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 178, in set_size_and_type
for index in range(start, stop) ]
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 178, in
for index in range(start, stop) ]
File "/usr/local/lib/python3.5/dist-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 78, in getitem
return getattr(self.obj, key)
AttributeError: _localName

Version and main components

  • Spyder Version: 3.2.4
  • Python Version: 3.5.2
  • Qt Versions: 5.9.1, PyQt5 5.9 on Linux

Dependencies

pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.19.2 (OK)
numpy >=1.7      :  1.13.1 (OK)
sphinx >=0.6.6   :  1.6.5 (OK)
rope >=0.9.4     :  0.10.7 (OK)
jedi >=0.9.0     :  0.11.0 (OK)
psutil >=0.3     :  5.4.0 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  None (NOK)
cython >=0.21    :  None (NOK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.2.1 (OK)
pylint >=0.25    :  1.7.4 (OK)

@ccordoba12
Copy link
Member

Thanks for reporting, but unfortunately your description is not complete. Please post the Python code you used to get variable2View along with a simple odt file we can use in our end to reproduce this problem.

Thanks!

@greenorca
Copy link
Author

greenorca commented Nov 11, 2017

Thanks for getting back to me, and my apologies for the incomplete information.
Instead of the odt file, I attached the content.xml extracted from the odt and had to rename it the txt...

content226_uifz_block6.txt

file = "content226_uifz_block6.txt"
if __name__ == '__main__':
    with open(file) as f:
        read_data = f.read()
        
    content = xml.dom.minidom.parseString(read_data)
    tables = content.getElementsByTagName("table:table")
    # the crash happens when opening the tables variable with VariableExplorer right after the above line

Generally speaking, the script does what I want it to do, extracting strings from the cells within tables[0] if I don't stop it. And sorry for dumping tables into writer documents, I know it is odd ;-)
screenshot_2017-11-11_09-16-33
screenshot_2017-11-11_09-16-15

@CAM-Gerlach CAM-Gerlach self-assigned this Mar 12, 2018
@CAM-Gerlach CAM-Gerlach added this to the v3.2.8 milestone Mar 12, 2018
@CAM-Gerlach
Copy link
Member

I've reproduced and fixed this by just catching the error where it occurs, and you are now able to view the dom.minidom.Element just fine. PR incoming shortly. More complete code to reproduce:

from xml.dom.minidom import parseString

file = "Data/content226_uifz_block6.txt"
with open(file) as f:
    read_data = f.read()

    content = parseString(read_data)
    tables = content.getElementsByTagName("table:table")

@CAM-Gerlach CAM-Gerlach changed the title Crash in Variable Explorer AttributeError when attempting to view dom.minidom.Element object in Variable Explorer Mar 12, 2018
CAM-Gerlach added a commit to CAM-Gerlach/spyder that referenced this issue Mar 12, 2018
CAM-Gerlach added a commit to CAM-Gerlach/spyder that referenced this issue Mar 12, 2018
ccordoba12 added a commit that referenced this issue Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants