Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: certifi/python-certifi
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2020.04.05
Choose a base ref
...
head repository: certifi/python-certifi
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2020.04.05.1
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 5, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d4e52bd View commit details
  2. 2020.04.05.1

    Lukasa committed Apr 5, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    87836b3 View commit details
Showing with 13 additions and 28 deletions.
  1. +1 −1 certifi/__init__.py
  2. +12 −27 certifi/core.py
2 changes: 1 addition & 1 deletion certifi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .core import contents, where

__version__ = "2020.04.05"
__version__ = "2020.04.05.1"
39 changes: 12 additions & 27 deletions certifi/core.py
Original file line number Diff line number Diff line change
@@ -6,40 +6,25 @@
This module returns the installation location of cacert.pem or its contents.
"""
import importlib
import os

try:
import importlib.resources
# Defeat lazy module importers.
importlib.resources.open_binary
_HAVE_RESOURCE_READER = True
from importlib.resources import read_text
except ImportError:
_HAVE_RESOURCE_READER = False

try:
import pkg_resources
# Defeat lazy module importers.
_HAVE_PKG_RESOURCES = True
except ImportError:
_HAVE_PKG_RESOURCES = False

_PACKAGE_NAME = "certifi"
_CACERT_NAME = "cacert.pem"
# This fallback will work for Python versions prior to 3.7 that lack the
# importlib.resources module but relies on the existing `where` function
# so won't address issues with environments like PyOxidizer that don't set
# __file__ on modules.
def read_text(_module, _path, encoding="ascii"):
with open(where(), "r", encoding=encoding) as data:
return data.read()


def where():
if _HAVE_PKG_RESOURCES:
return pkg_resources.resource_filename(_PACKAGE_NAME, _CACERT_NAME)
else:
mod = importlib.import_module(_PACKAGE_NAME)
path = os.path.dirname(mod.__file__)
return os.path.join(path, _CACERT_NAME)
f = os.path.dirname(__file__)

return os.path.join(f, "cacert.pem")


def contents():
if _HAVE_RESOURCE_READER:
return importlib.resources.read_text(_PACKAGE_NAME, _CACERT_NAME, encoding="ascii")
else:
with open(where(), "r", encoding="ascii") as data:
return data.read()
return read_text("certifi", "cacert.pem", encoding="ascii")