Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Python 3 compatibility changes

  • Loading branch information...
commit dde4597c894bd92be8d867ec9724b462fa484285 1 parent 7d283f7
Angelo Dell'Aera authored

Showing 1 changed file with 9 additions and 4 deletions. Show diff stats Hide diff stats

  1. +9 4 src/pylibemu.pyx
13 src/pylibemu.pyx
@@ -21,7 +21,12 @@ cimport pylibemu
21 21
22 22 import sys
23 23 import socket
24   -import urllib2
  24 +
  25 +try:
  26 + import urllib.request as urllib2
  27 +except ImportError:
  28 + import urllib2
  29 +
25 30 import hashlib
26 31 import logging
27 32
@@ -74,9 +79,9 @@ cdef uint32_t URLDownloadToFile(c_emu_env *env, c_emu_env_hook *hook...):
74 79 lpfnCB = <void *>va_arg(args, void_ptr_type)
75 80 va_end(args)
76 81
77   - logging.warning("Downloading %s (%s)" % (szURL, szFileName))
  82 + logging.warning("Downloading %s (%s)" % (szURL.decode('utf-8'), szFileName.decode('utf-8')))
78 83 try:
79   - url = urllib2.urlopen(szURL, timeout = 10)
  84 + url = urllib2.urlopen(szURL.decode('utf-8'), timeout = 10)
80 85 content = url.read()
81 86 except:
82 87 logging.warning("Error while downloading from %s" % (szURL, ))
@@ -527,7 +532,7 @@ cdef class Emulator:
527 532 emu_cpu_reg32_set(emu_cpu_get(self._emu), esp, 0x0012fe98)
528 533
529 534 cdef check_stop_emulation(self, c_emu_env_hook *hook):
530   - return str(hook.hook.win.fnname) in ('ExitProcess', 'ExitThread', 'exit')
  535 + return hook.hook.win.fnname.decode('utf-8') in ('ExitProcess', 'ExitThread', 'exit')
531 536
532 537 cpdef int test(self, steps = 1000000):
533 538 '''

0 comments on commit dde4597

Please sign in to comment.
Something went wrong with that request. Please try again.