diff options
| author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2019-07-13 03:19:50 -0700 |
|---|---|---|
| committer | Paul Ganssle <pganssle@users.noreply.github.com> | 2019-07-13 12:19:50 +0200 |
| commit | 67344c95b9402b4720d3c9e61d01096a6453efa6 (patch) | |
| tree | 09eab1a8e3a27e2b070b2cc8dbaa002afe3eacf8 /pkg_resources/__init__.py | |
| parent | 46be0276c7a3b95240ce36055d5ce73ab455e756 (diff) | |
| download | python-setuptools-git-67344c95b9402b4720d3c9e61d01096a6453efa6.tar.gz | |
Fix #1790 : Include the file path in get_metadata() UnicodeDecodeErrors (#1791)
Include the file path in get_metadata() UnicodeDecodeErrors.
Diffstat (limited to 'pkg_resources/__init__.py')
| -rw-r--r-- | pkg_resources/__init__.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 97e08d68..1f170cfd 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1416,8 +1416,17 @@ class NullProvider: def get_metadata(self, name): if not self.egg_info: return "" - value = self._get(self._fn(self.egg_info, name)) - return value.decode('utf-8') if six.PY3 else value + path = self._get_metadata_path(name) + value = self._get(path) + if six.PY2: + return value + try: + return value.decode('utf-8') + except UnicodeDecodeError as exc: + # Include the path in the error message to simplify + # troubleshooting, and without changing the exception type. + exc.reason += ' in {} file at path: {}'.format(name, path) + raise def get_metadata_lines(self, name): return yield_lines(self.get_metadata(name)) |
