Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
f10da56e
Commit
f10da56e
authored
Sep 27, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Plain Diff
Merge fix for issue #719.
parents
2b5937f5
69061481
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
CHANGES.rst
CHANGES.rst
+3
-0
pkg_resources/__init__.py
pkg_resources/__init__.py
+13
-8
No files found.
CHANGES.rst
View file @
f10da56e
...
@@ -13,6 +13,9 @@ v28.0.0
...
@@ -13,6 +13,9 @@ v28.0.0
*
#
795
:
Bump
certifi
.
*
#
795
:
Bump
certifi
.
*
#
719
:
Suppress
decoding
errors
and
instead
log
a
warning
when
metadata
cannot
be
decoded
.
v27
.3.1
v27
.3.1
-------
-------
...
...
pkg_resources/__init__.py
View file @
f10da56e
# coding: utf-8
"""
"""
Package resource API
Package resource API
--------------------
--------------------
...
@@ -1858,17 +1860,20 @@ class FileMetadata(EmptyProvider):
...
@@ -1858,17 +1860,20 @@ class FileMetadata(EmptyProvider):
def get_metadata(self, name):
def get_metadata(self, name):
if name == 'PKG-INFO':
if name == 'PKG-INFO':
with io.open(self.path, encoding='utf-8') as f:
with io.open(self.path, encoding='utf-8', errors="replace") as f:
try:
metadata = f.read()
metadata = f.read()
self._warn_on_replacement(metadata)
except UnicodeDecodeError as exc:
# add path context to error message
tmpl = " in {self.path}"
exc.reason += tmpl.format(self=self)
raise
return metadata
return metadata
raise KeyError("No metadata except PKG-INFO is available")
raise KeyError("No metadata except PKG-INFO is available")
def _warn_on_replacement(self, metadata):
# Python 2.6 and 3.2 compat for: replacement_char = '�'
replacement_char = b'
\
xef
\
xbf
\
xbd
'.decode('utf-8')
if replacement_char in metadata:
tmpl = "{self.path} could not be properly decoded in UTF-8"
msg = tmpl.format(**locals())
warnings.warn(msg)
def get_metadata_lines(self, name):
def get_metadata_lines(self, name):
return yield_lines(self.get_metadata(name))
return yield_lines(self.get_metadata(name))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment