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

Skip to content

Commit f6a9f98

Browse files
committed
Avoid recursion for subclasses of str that are also "PathLike"
This is the case for path.py for example. Fixes gh-11306
1 parent b5b9a63 commit f6a9f98

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

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)