summaryrefslogtreecommitdiff
path: root/pkg_resources
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-08-04 13:14:45 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-08-04 13:14:45 -0400
commit21efdb5615f98a60cfa0b6130a1c2d93e5faa28e (patch)
treecd68db3575737e34f9c13fec76df8ba06e330e79 /pkg_resources
parentaa835dcab3b98944c928a73eab8b091479514155 (diff)
downloadpython-setuptools-git-21efdb5615f98a60cfa0b6130a1c2d93e5faa28e.tar.gz
Allow an environment to suppress errors when reading metadata by setting PKG_RESOURCES_METADATA_ERRORS='replace'. Ref #719.
Diffstat (limited to 'pkg_resources')
-rw-r--r--pkg_resources/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index 2a053b50..b402ddd6 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -1859,7 +1859,9 @@ class FileMetadata(EmptyProvider):
def get_metadata(self, name):
if name=='PKG-INFO':
- with io.open(self.path, encoding='utf-8') as f:
+ env_key = 'PKG_RESOURCES_METADATA_ERRORS'
+ errors = os.environ.get(env_key, 'strict')
+ with io.open(self.path, encoding='utf-8', errors=errors) as f:
try:
metadata = f.read()
except UnicodeDecodeError as exc: