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

_create_tmp_config_dir() "mkdirs" the returned dir #4591

Merged
merged 2 commits into from Jul 7, 2015

Conversation

curufinwe
Copy link
Contributor

Fixes #4120

@tacaswell tacaswell added this to the next point release milestone Jul 6, 2015
@@ -547,6 +548,11 @@ def _create_tmp_config_dir():
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
os.environ['MPLCONFIGDIR'] = tempdir

try:
mkdirs(tempdir)
except OSError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not eat the exception here, this leaves the user in the same situation as before if this fails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cbook.py already has a safe mkdirs(). Unfortunately, Python's mkdirs() has
some nasty race conditions and other problems, so you should use the safe
mkdirs.
On Jul 6, 2015 12:48 PM, "Thomas A Caswell" notifications@github.com
wrote:

In lib/matplotlib/init.py
#4591 (comment):

@@ -547,6 +548,11 @@ def _create_tmp_config_dir():
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
os.environ['MPLCONFIGDIR'] = tempdir

  • try:
  •    mkdirs(tempdir)
    
  • except OSError:

I would not eat the exception here, this leaves the user in the same
situation as before if this fails.


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/4591/files#r33955250.

@curufinwe
Copy link
Contributor Author

I am using the cbook.py mkdirs.

@tacaswell
Copy link
Member

Thanks for looking into this. I am going to merge this as-is, but I think this needs a more-through overhaul to use temfile.mkdtemp https://docs.python.org/2/library/tempfile.html#tempfile.mkdtemp which will do almost all of this work for us.

tacaswell added a commit that referenced this pull request Jul 7, 2015
FIX: _create_tmp_config_dir() "mkdirs" the returned dir
@tacaswell tacaswell merged commit 906c61e into matplotlib:master Jul 7, 2015
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.

None yet

3 participants