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

MNT: make certifi actually optional#18670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:masterfromtacaswell:optional_cerifi
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletionslib/matplotlib/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,7 +717,11 @@ def is_url(filename):

@functools.lru_cache()
def _get_ssl_context():
import certifi
try:
import certifi
except ImportError:
_log.debug("Could not import certifi.")
return None
import ssl
return ssl.create_default_context(cafile=certifi.where())

Expand All@@ -726,7 +730,12 @@ def _get_ssl_context():
def _open_file_or_url(fname):
if not isinstance(fname, Path) and is_url(fname):
import urllib.request
with urllib.request.urlopen(fname, context=_get_ssl_context()) as f:
ssl_ctx = _get_ssl_context()
if ssl_ctx is None:
_log.debug(
"Could not get certifi ssl context, https may not work."
)
with urllib.request.urlopen(fname, context=ssl_ctx) as f:
yield (line.decode('utf-8') for line in f)
else:
fname = os.path.expanduser(fname)
Expand Down
8 changes: 6 additions & 2 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1478,8 +1478,12 @@ def imread(fname, format=None):
if len(parsed.scheme) > 1: # Pillow doesn't handle URLs directly.
# hide imports to speed initial import on systems with slow linkers
from urllib import request
with request.urlopen(fname,
context=mpl._get_ssl_context()) as response:
ssl_ctx = mpl._get_ssl_context()
if ssl_ctx is None:
_log.debug(
"Could not get certifi ssl context, https may not work."
)
with request.urlopen(fname, context=ssl_ctx) as response:
import io
try:
response.seek(0)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp