Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8083f25

Browse filesBrowse files
committed
shutil.move: Guard against IOError and print warnings instead of crashing.
1 parent 9e477b3 commit 8083f25
Copy full SHA for 8083f25

File tree

Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ def matplotlib_fname():
642642
WARNING: Old rc filename ".matplotlibrc" found in working dir
643643
and and renamed to new default rc file name "matplotlibrc"
644644
(no leading"dot"). """, file=sys.stderr)
645-
shutil.move('.matplotlibrc', 'matplotlibrc')
645+
try:
646+
shutil.move('.matplotlibrc', 'matplotlibrc')
647+
except IOError as e:
648+
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)
646649

647650
home = get_home()
648651
oldname = os.path.join( home, '.matplotlibrc')
@@ -653,7 +656,10 @@ def matplotlib_fname():
653656
WARNING: Old rc filename "%s" found and renamed to
654657
new default rc file name "%s"."""%(oldname, newname), file=sys.stderr)
655658

656-
shutil.move(oldname, newname)
659+
try:
660+
shutil.move(oldname, newname)
661+
except IOError as e:
662+
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)
657663

658664

659665
fname = os.path.join( os.getcwd(), 'matplotlibrc')

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ class TexManager:
102102
WARNING: found a TeX cache dir in the deprecated location "%s".
103103
Moving it to the new default location "%s".""" % (oldcache, texcache),
104104
file=sys.stderr)
105-
shutil.move(oldcache, texcache)
105+
try:
106+
shutil.move(oldcache, texcache)
107+
except IOError as e:
108+
print("WARNING: File could not be renamed: %s" % e, file=sys.stderr)
106109
mkdirs(texcache)
107110

108111
_dvipng_hack_alpha = None

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.