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

CI Error AttributeError: 'ExcelFile' object has no attribute 'engine' #30217

Closed
WillAyd opened this issue Dec 11, 2019 · 3 comments · Fixed by #30255
Closed

CI Error AttributeError: 'ExcelFile' object has no attribute 'engine' #30217

WillAyd opened this issue Dec 11, 2019 · 3 comments · Fixed by #30255
Labels
CI Continuous Integration IO Excel read_excel, to_excel

Comments

@WillAyd
Copy link
Member

WillAyd commented Dec 11, 2019

Showing up in

https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=22986&view=logs

Traceback (most recent call last):
  File "D:\a\1\s\pandas\io\excel\_base.py", line 907, in __del__
    self.close()
  File "D:\a\1\s\pandas\io\excel\_base.py", line 890, in close
    if self.engine == "openpyxl":
AttributeError: 'ExcelFile' object has no attribute 'engine'

Looks to be caused by changes in #30096 - I think need to make it self.reader.engine. But definitely shows this code getting hit

@jbrockmendel

@jbrockmendel
Copy link
Member

yah, ive been seeing that locally ocassionally. last time i looked at it i concluded that self.engine is correct, and best guess is that since this is happening inside __del__, something weird is going on with __dict__ getting cleared out. Hopefully I'm wrong on this and changing self.engine -> self.reader.engine fixes it.

@WillAyd
Copy link
Member Author

WillAyd commented Dec 11, 2019

Hmm actually that's a good point. I misread that engine was never an attribute of the ExcelFile but that's not true

@jbrockmendel jbrockmendel added CI Continuous Integration IO Excel read_excel, to_excel labels Dec 13, 2019
@jorisvandenbossche
Copy link
Member

I think the code in the __del__ function can be wrapped in a try / except to hide those errors. When python is cleaning up, you are not exactly sure about the order, so certain variables that are accessed in the __del__ method can already be deleted before the parent object is (see warning box at https://docs.python.org/3/reference/datamodel.html#object.__del__)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration IO Excel read_excel, to_excel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants