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

Skip to content

Commit d5d2b2a

Browse files
authored
Merge pull request #19517 from anntzer/unurl
Deprecate toplevel is_url, URL_REGEX helpers.
2 parents b0aab9f + fc342ab commit d5d2b2a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``is_url`` and ``URL_REGEX``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated. (They were previously defined in the toplevel
4+
:mod:`matplotlib` module.)

lib/matplotlib/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,11 @@ def rc_params(fail_on_error=False):
665665
return rc_params_from_file(matplotlib_fname(), fail_on_error)
666666

667667

668+
# Deprecated in Matplotlib 3.5.
668669
URL_REGEX = re.compile(r'^http://|^https://|^ftp://|^file:')
669670

670671

672+
@_api.deprecated("3.5")
671673
def is_url(filename):
672674
"""Return whether *filename* is an http, https, ftp, or file URL path."""
673675
return URL_REGEX.match(filename) is not None
@@ -686,7 +688,8 @@ def _get_ssl_context():
686688

687689
@contextlib.contextmanager
688690
def _open_file_or_url(fname):
689-
if not isinstance(fname, Path) and is_url(fname):
691+
if (isinstance(fname, str)
692+
and fname.startswith(('http://', 'https://', 'ftp://', 'file:'))):
690693
import urllib.request
691694
ssl_ctx = _get_ssl_context()
692695
if ssl_ctx is None:

0 commit comments

Comments
 (0)