From c7873d38c4478f86864666cd1231877d1183b820 Mon Sep 17 00:00:00 2001 From: riot Date: Thu, 7 Apr 2016 14:39:32 +0200 Subject: This helps finding packages with bad utf Checking hundreds of possibly installed packages manually should NOT be expected of the user ;) --- pkg_resources/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg_resources/__init__.py') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 08677719..8eb697f4 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1859,7 +1859,10 @@ class FileMetadata(EmptyProvider): def get_metadata(self, name): if name=='PKG-INFO': with io.open(self.path, encoding='utf-8') as f: - metadata = f.read() + try: + metadata = f.read() + except UnicodeDecodeError as e: + raise Exception("Bad utf in package: %s - %s" % (self.path, e)) return metadata raise KeyError("No metadata except PKG-INFO is available") -- cgit v1.2.1