1. Daniel Holth
  2. wheel

Commits

Paul Moore  committed 61d8b41

Use wheel.pkginfo in wheel.install

  • Participants
  • Parent commits 93cb8c1
  • Branches default

Comments (0)

Files changed (2)

File wheel/install.py

View file
 import zipfile
 import hashlib
 import csv
-from email.parser import Parser
 
 from wheel.decorator import reify
 from wheel.util import urlsafe_b64encode, from_json,\
     urlsafe_b64decode, native, binary
 from wheel import signatures
+from wheel.pkginfo import read_pkg_info_bytes
 
 # The next major version after this version of the 'wheel' tool:
 VERSION_TOO_HIGH = (1, 0)
     @reify
     def parsed_wheel_info(self):
         """Parse wheel metadata"""
-        return Parser().parse(self.zipfile.open(self.wheelinfo_name))
+        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
 
     def check_version(self):
         version = self.parsed_wheel_info['Wheel-Version']

File wheel/pkginfo.py

View file
 if not _PY3:
     from email.generator import Generator
     
+    def read_pkg_info_bytes(bytestr):
+        return Parser().parsestr(bytestr)
+
     def read_pkg_info(path):
         with open(path, "r") as headers:
             message = Parser().parse(headers)
 
 else:
     from email.generator import BytesGenerator
+    def read_pkg_info_bytes(bytestr):
+        headers = bytestr.decode(encoding="ascii", errors="surrogateescape")
+        message = Parser().parsestr(headers)
+        return message
+
     def read_pkg_info(path):
         with open(path, "r", 
                   encoding="ascii",