Changeset 948:483488585dd8


Ignore:
Timestamp:
05/07/19 18:31:40 (6 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Encoding handling is fixed during update (re #347).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/update.py

    r919 r948  
    1111import hashlib
    1212import traceback
     13import io
    1314
    1415if os.name=="nt":
     
    195196    def _send(self, words):
    196197        """Send the given words via the socket."""
    197         self._sock.send("\t".join(words) + "\n")
     198        self._sock.send(bytes("\t".join(words) + "\n", "utf-8"))
    198199
    199200#------------------------------------------------------------------------------
     
    226227    try:
    227228        updateManifest = Manifest()
    228         f= urllib.request.urlopen(updateURL + "/" + manifestName)
    229         updateManifest.readFrom(f)
     229        reply = urllib.request.urlopen(updateURL + "/" + manifestName)
     230        charset = reply.headers.get_content_charset()
     231        content = reply.read().decode("utf-8" if charset is None else charset)
     232        updateManifest.readFrom(io.StringIO(content))
    230233
    231234    except Exception as e:
     
    290293        try:
    291294            sum = hashlib.md5()
    292             sum.update(path)
     295            sum.update(bytes(path, "utf-8"))
    293296            toremoveDir = getToremoveDir(toremoveDir, directory)
    294297            targetPath = os.path.join(toremoveDir, sum.hexdigest())
     
    505508                break;
    506509
    507             buffer += data
     510            buffer += str(data, "utf-8")
    508511            buffer = processMLXUpdate(buffer, listener)
    509512
Note: See TracChangeset for help on using the changeset viewer.