Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit358b290

Browse files
authored
Merge pull request#25299 from meeseeksmachine/auto-backport-of-pr-25238-on-v3.7.x
Backport PR#25238 on branch v3.7.x (Check file path for animation and raise if it does not exist)
2 parentse4a3b14 +08293ca commit358b290

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎lib/matplotlib/animation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ def setup(self, fig, outfile, dpi=None):
193193
The DPI (or resolution) for the file. This controls the size
194194
in pixels of the resulting movie file.
195195
"""
196+
# Check that path is valid
197+
Path(outfile).parent.resolve(strict=True)
196198
self.outfile=outfile
197199
self.fig=fig
198200
ifdpiisNone:
@@ -405,6 +407,8 @@ def setup(self, fig, outfile, dpi=None, frame_prefix=None):
405407
deleted by `finish`; if not *None*, no temporary files are
406408
deleted.
407409
"""
410+
# Check that path is valid
411+
Path(outfile).parent.resolve(strict=True)
408412
self.fig=fig
409413
self.outfile=outfile
410414
ifdpiisNone:
@@ -423,7 +427,7 @@ def setup(self, fig, outfile, dpi=None, frame_prefix=None):
423427
self.fname_format_str='%s%%07d.%s'
424428

425429
def__del__(self):
426-
ifself._tmpdir:
430+
ifhasattr(self,'_tmpdir')andself._tmpdir:
427431
self._tmpdir.cleanup()
428432

429433
@property

‎lib/matplotlib/tests/test_animation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,3 +506,13 @@ def test_disable_cache_warning(anim):
506506
)
507507
assertanim._cache_frame_dataisFalse
508508
anim._init_draw()
509+
510+
511+
deftest_movie_writer_invalid_path(anim):
512+
ifsys.platform=="win32":
513+
match_str=re.escape("[WinError 3] The system cannot find the path specified:")
514+
else:
515+
match_str=re.escape("[Errno 2] No such file or directory: '/foo")
516+
withpytest.raises(FileNotFoundError,match=match_str):
517+
_=anim.save("/foo/bar/aardvark/thiscannotreallyexist.mp4",
518+
writer=animation.FFMpegFileWriter())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp