Skip to content

Commit 0231fae

Browse files
authored
Merge pull request #11307 from Nodd/path.py
Avoid recursion for subclasses of str that are also "PathLike" in to_filehandle()
2 parents b5b9a63 + f6a9f98 commit 0231fae

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,7 @@ def to_filehandle(fname, flag='rU', return_opened=False, encoding=None):
452452
read/write flag for :func:`file`
453453
"""
454454
if isinstance(fname, getattr(os, "PathLike", ())):
455-
return to_filehandle(
456-
os.fspath(fname),
457-
flag=flag, return_opened=return_opened, encoding=encoding)
455+
fname = os.fspath(fname)
458456
if isinstance(fname, str):
459457
if fname.endswith('.gz'):
460458
# get rid of 'U' in flag for gzipped files.

0 commit comments

Comments
 (0)