Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Keep references to modules required in pgf LatexManager destructor #5249

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

Merged
merged 1 commit into from
Dec 2, 2015
Merged

Keep references to modules required in pgf LatexManager destructor #5249

merged 1 commit into from
Dec 2, 2015

Conversation

pwuertz
Copy link
Contributor

@pwuertz pwuertz commented Oct 15, 2015

Alternative fix to issue described in #5144.
The __del__ method in LatexManager requires globals like os and shutil, which may not be present anymore at the time the method is called. Keep local references to the required modules within the instance.

@mdboom
Copy link
Member

mdboom commented Oct 15, 2015

I'm sure that's a solution but sure feels icky. Not that we shouldn't merge if we don't find anything better. Does putting inline imports in __del__ work or does importing from del introduce its own set of problems? Somehow that feels less likely to break in the future.

@pwuertz
Copy link
Contributor Author

pwuertz commented Oct 15, 2015

I remember a problem like this from another project, but I don't really remember what was the correct solution, reimport or holding on to a reference. I don't know or forgot how to provoke such errors though.

Maybe one could also tweak LatexManager a bit so it doesn't involve __del__ at all, that would probably be the cleanest and most pythonic solution. But then I would have to re-test the reliable deletion of temp files again and I don't have a windows system at disposal.

@tacaswell
Copy link
Member

Is this a case where atexit functions would be useful?

@kwankyu
Copy link

kwankyu commented Nov 5, 2015

The problem is specifically with __del__ method in LatexManager. atexit is already used in the module but the __del__ method seems necessary for other times than shutdown.

As I initially reported, the problem that this patch deals with popped up in the project Sage. See http://trac.sagemath.org/ticket/14798 This ticket will be closed once any solution is merged to matplotlib.

If other solution is suggested, then I can test it with Sage. Also the problem is not only with Windows. My Sage installation is on Mac.

@kwankyu
Copy link

kwankyu commented Dec 2, 2015

I am writing since I am wondering what would be done for this pull request, as I am ignorant of the general policies of matplotlib development. For this pull request to be accepted for a merge to the next release of matplotlib, should someone give a positive review or is this just up to the release manager?

The solution in this pull request works though I am not completely satisfied with its method. So I would be happy if this pull request is accepted, unless someone proposes a better solution.

@mdboom mdboom added this to the Critical bugfix release (1.5.1) milestone Dec 2, 2015
@mdboom
Copy link
Member

mdboom commented Dec 2, 2015

Yeah -- we should probably hold our noses and merge as-is. 😉

mdboom added a commit that referenced this pull request Dec 2, 2015
Keep references to modules required in pgf LatexManager destructor
@mdboom mdboom merged commit 33cda40 into matplotlib:master Dec 2, 2015
@mdboom
Copy link
Member

mdboom commented Dec 2, 2015

Backported to 1.5.x as a561593

mdboom added a commit that referenced this pull request Dec 2, 2015
Keep references to modules required in pgf LatexManager destructor
@pwuertz pwuertz deleted the fix_5144 branch February 24, 2016 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants