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

Skip to content

Commit fc342ab

Browse files
committed
Deprecate toplevel is_url, URL_REGEX helpers.
They certainly don't warrant being defined at the toplevel. Also, we don't actually need regexes here.
1 parent 56d9e7c commit fc342ab

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
@@ -661,9 +661,11 @@ def rc_params(fail_on_error=False):
661661
return rc_params_from_file(matplotlib_fname(), fail_on_error)
662662

663663

664+
# Deprecated in Matplotlib 3.5.
664665
URL_REGEX = re.compile(r'^http://|^https://|^ftp://|^file:')
665666

666667

668+
@_api.deprecated("3.5")
667669
def is_url(filename):
668670
"""Return whether *filename* is an http, https, ftp, or file URL path."""
669671
return URL_REGEX.match(filename) is not None
@@ -682,7 +684,8 @@ def _get_ssl_context():
682684

683685
@contextlib.contextmanager
684686
def _open_file_or_url(fname):
685-
if not isinstance(fname, Path) and is_url(fname):
687+
if (isinstance(fname, str)
688+
and fname.startswith(('http://', 'https://', 'ftp://', 'file:'))):
686689
import urllib.request
687690
ssl_ctx = _get_ssl_context()
688691
if ssl_ctx is None:

0 commit comments

Comments
 (0)