diff --git a/src/m64py/SDL/darwin.py b/src/m64py/SDL/darwin.py index 33e34d2..bf39104 100644 --- a/src/m64py/SDL/darwin.py +++ b/src/m64py/SDL/darwin.py @@ -109,7 +109,7 @@ def WMEnable(name=None): if name is None: name = os.path.splitext(os.path.basename(sys.argv[0]))[0] if isinstance(name, unicode): - name = name.encode('utf-8') + name = name.encode() if not hasattr(objc, 'loadBundleFunctions'): return False bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework')) diff --git a/src/m64py/SDL/video.py b/src/m64py/SDL/video.py index d68e9fe..e946083 100644 --- a/src/m64py/SDL/video.py +++ b/src/m64py/SDL/video.py @@ -1540,7 +1540,7 @@ def SDL_WM_SetCaption(title, icon): - `title`: string - `icon`: string ''' - _SDL_WM_SetCaption(title.encode('utf-8'), icon.encode('utf-8')) + _SDL_WM_SetCaption(title.encode(), icon.encode()) _SDL_WM_GetCaption = private_function('SDL_WM_GetCaption', @@ -1557,12 +1557,12 @@ def SDL_WM_GetCaption(): _SDL_WM_GetCaption(byref(title), byref(icon)) if title.value: - title = title.value.decode('utf-8') + title = title.value.decode() else: title = None if icon.value: - icon = icon.value.decode('utf-8') + icon = icon.value.decode() else: icon = None return title, icon diff --git a/src/m64py/core/config.py b/src/m64py/core/config.py index 024942b..c285aa8 100644 --- a/src/m64py/core/config.py +++ b/src/m64py/core/config.py @@ -66,7 +66,7 @@ class Config: config_ptr = C.c_void_p() self.m64p.ConfigOpenSection.argtypes = [C.c_char_p, C.c_void_p] rval = self.m64p.ConfigOpenSection( - C.c_char_p(section), C.byref(config_ptr)) + C.c_char_p(section.encode()), C.byref(config_ptr)) if rval != M64ERR_SUCCESS: log.debug("open_section()") log.warn(self.core.error_message(rval)) @@ -87,7 +87,7 @@ class Config: return rval def has_unsaved_changes(self, section): - rval = self.m64p.ConfigHasUnsavedChanges(C.c_char_p(section)) + rval = self.m64p.ConfigHasUnsavedChanges(C.c_char_p(section.encode())) if rval == 0: return False else: @@ -95,7 +95,7 @@ class Config: def delete_section(self, section): """Deletes a section from the config.""" - rval = self.m64p.ConfigDeleteSection(C.c_char_p(section)) + rval = self.m64p.ConfigDeleteSection(C.c_char_p(section.encode())) if rval != M64ERR_SUCCESS: log.debug("delete_section()") log.warn(self.core.error_message(rval)) @@ -112,7 +112,7 @@ class Config: def save_section(self, section): """Saves one section of the current configuration to disk, while leaving the other sections unmodified.""" - rval = self.m64p.ConfigSaveSection(C.c_char_p(section)) + rval = self.m64p.ConfigSaveSection(C.c_char_p(section.encode())) if rval != M64ERR_SUCCESS: log.debug("save_section()") log.warn(self.core.error_message(rval)) @@ -122,7 +122,7 @@ class Config: """Reverts changes previously made to one section of the current configuration file, so that it will match with the configuration at the last time that it was loaded from or saved to disk. """ - rval = self.m64p.ConfigRevertChanges(C.c_char_p(section)) + rval = self.m64p.ConfigRevertChanges(C.c_char_p(section.encode())) if rval != M64ERR_SUCCESS: log.debug("revert_changes()") log.warn(self.core.error_message(rval)) @@ -146,7 +146,7 @@ class Config: self.m64p.ConfigSetParameter.argtypes = [ C.c_void_p, C.c_char_p, C.c_int, param_arg_type] rval = self.m64p.ConfigSetParameter( - self.config_handle, C.c_char_p(param_name), + self.config_handle, C.c_char_p(param_name.encode()), C.c_int(param_type), param_value) if rval != M64ERR_SUCCESS: log.debug("set_parameter()") @@ -170,7 +170,7 @@ class Config: self.m64p.ConfigGetParameter.argtypes = [ C.c_void_p, C.c_char_p, C.c_int, C.c_void_p, C.c_int] rval = self.m64p.ConfigGetParameter( - self.config_handle, C.c_char_p(param_name), + self.config_handle, C.c_char_p(param_name.encode()), C.c_int(param_type), param_value, C.c_int(maxsize)) if rval != M64ERR_SUCCESS: log.debug("get_parameter()") @@ -188,7 +188,7 @@ class Config: self.m64p.ConfigGetParameterHelp.argtypes = [ C.c_void_p, C.c_char_p, C.POINTER(C.c_int)] rval = self.m64p.ConfigGetParameterType( - self.config_handle, C.c_char_p(param_name), param_type) + self.config_handle, C.c_char_p(param_name.encode()), param_type) if rval != M64ERR_SUCCESS: log.debug("get_parameter_type()") log.warn(self.core.error_message(rval)) @@ -200,7 +200,7 @@ class Config: self.m64p.ConfigGetParameterHelp.restype = C.c_char_p self.m64p.ConfigGetParameterHelp.argtypes = [C.c_void_p, C.c_char_p] rval = self.m64p.ConfigGetParameterHelp( - self.config_handle, C.c_char_p(param_name)) + self.config_handle, C.c_char_p(param_name.encode())) return rval def set_default(self, param_type, param_name, param_value, param_help): @@ -209,20 +209,20 @@ class Config: param_ctype = M64_CTYPE[param_type] if param_type == M64TYPE_INT: rval = self.m64p.ConfigSetDefaultInt( - self.config_handle, C.c_char_p(param_name), - param_ctype(param_value), C.c_char_p(param_help)) + self.config_handle, C.c_char_p(param_name.encode()), + param_ctype(param_value), C.c_char_p(param_help.encode())) elif param_type == M64TYPE_FLOAT: rval = self.m64p.ConfigSetDefaultFloat( - self.config_handle, C.c_char_p(param_name), - param_ctype(param_value), C.c_char_p(param_help)) + self.config_handle, C.c_char_p(param_name.encode()), + param_ctype(param_value), C.c_char_p(param_help.encode())) elif param_type == M64TYPE_BOOL: rval = self.m64p.ConfigSetDefaultBool( - self.config_handle, C.c_char_p(param_name), - param_ctype(param_value), C.c_char_p(param_help)) + self.config_handle, C.c_char_p(param_name.encode()), + param_ctype(param_value), C.c_char_p(param_help.encode())) elif param_type == M64TYPE_STRING: rval = self.m64p.ConfigSetDefaultString( - self.config_handle, C.c_char_p(param_name), - param_ctype(param_value), C.c_char_p(param_help)) + self.config_handle, C.c_char_p(param_name.encode()), + param_ctype(param_value), C.c_char_p(param_help.encode())) return rval def get_path(self, path="UserConfig"): @@ -230,7 +230,7 @@ class Config: if path == "SharedData": self.m64p.ConfigGetSharedDataFilepath.restype = C.c_char_p rval = self.m64p.ConfigGetSharedDataFilepath( - C.c_char_p("mupen64plus.ini")) + C.c_char_p("mupen64plus.ini".encode())) elif path == "UserConfig": self.m64p.ConfigGetUserConfigPath.restype = C.c_char_p rval = self.m64p.ConfigGetUserConfigPath() @@ -241,6 +241,6 @@ class Config: self.m64p.ConfigGetUserCachePath.restype = C.c_char_p rval = self.m64p.ConfigGetUserCachePath() if rval: - return os.path.dirname(rval) + return os.path.dirname(rval.decode()) else: return rval diff --git a/src/m64py/core/core.py b/src/m64py/core/core.py index deaa4ae..0ff9e21 100644 --- a/src/m64py/core/core.py +++ b/src/m64py/core/core.py @@ -33,13 +33,13 @@ from m64py.core.vidext import vidext def debug_callback(context, level, message): if level <= M64MSG_ERROR: - sys.stderr.write("%s: %s\n" % (context, message)) + sys.stderr.write("%s: %s\n" % (context.decode(), message.decode())) elif level == M64MSG_WARNING: - sys.stderr.write("%s: %s\n" % (context, message)) + sys.stderr.write("%s: %s\n" % (context.decode(), message.decode())) elif level == M64MSG_INFO or level == M64MSG_STATUS: - sys.stderr.write("%s: %s\n" % (context, message)) + sys.stderr.write("%s: %s\n" % (context.decode(), message.decode())) elif level == M64MSG_VERBOSE and VERBOSE: - sys.stderr.write("%s: %s\n" % (context, message)) + sys.stderr.write("%s: %s\n" % (context.decode(), message.decode())) def state_callback(context, param, value): @@ -160,8 +160,8 @@ class Core: """Initializes libmupen64plus for use by allocating memory, creating data structures, and loading the configuration file.""" rval = self.m64p.CoreStartup( - C.c_int(CORE_API_VERSION), None, C.c_char_p(os.path.dirname(path)), - "Core", DEBUG_CALLBACK, "State", STATE_CALLBACK) + C.c_int(CORE_API_VERSION), None, C.c_char_p(os.path.dirname(path).encode()), + C.c_char_p(b"Core"), DEBUG_CALLBACK, C.c_char_p(b"State"), STATE_CALLBACK) if rval == M64ERR_SUCCESS: if use_vidext: self.override_vidext() @@ -197,7 +197,7 @@ class Core: else: if rval == M64ERR_SUCCESS: return (type_ptr.contents.value, ver_ptr.contents.value, api_ptr.contents.value, - name_ptr.contents.value, cap_ptr.contents.value) + name_ptr.contents.value.decode(), cap_ptr.contents.value) else: log.debug("plugin_get_version()") log.warn(self.error_message(rval)) @@ -272,7 +272,7 @@ class Core: plugin_name)) else: log.info("using %s plugin: '%s' v%s" % ( - plugin_name, plugin_desc, version_split(plugin_version))) + plugin_name.decode(), plugin_desc, version_split(plugin_version))) def detach_plugins(self): """Detaches plugins from the emulator core, @@ -399,7 +399,7 @@ class Core: def state_load(self, state_path=None): """Loads a saved state file from the current slot.""" - path = C.c_char_p(state_path) if state_path else None + path = C.c_char_p(state_path.encode()) if state_path else None rval = self.m64p.CoreDoCommand( M64CMD_STATE_LOAD, C.c_int(1), path) if rval != M64ERR_SUCCESS: @@ -409,7 +409,7 @@ class Core: def state_save(self, state_path=None, state_type=1): """Saves a state file to the current slot.""" - path = C.c_char_p(state_path) if state_path else None + path = C.c_char_p(state_path.encode()) if state_path else None rval = self.m64p.CoreDoCommand( M64CMD_STATE_SAVE, C.c_int(state_type), path) if rval != M64ERR_SUCCESS: @@ -500,7 +500,7 @@ class Core: """Adds a Cheat Function to a list of currently active cheats which are applied to the open ROM, and set its state to Enabled""" rval = self.m64p.CoreAddCheat( - C.c_char_p(cheat_name), C.pointer(cheat_code), + C.c_char_p(cheat_name.encode()), C.pointer(cheat_code), C.c_int(C.sizeof(cheat_code))) if rval != M64ERR_SUCCESS: log.debug("add_cheat()") @@ -513,7 +513,7 @@ class Core: def cheat_enabled(self, cheat_name, enabled=True): """Enables or disables a specified Cheat Function""" rval = self.m64p.CoreCheatEnabled( - C.c_char_p(cheat_name), C.c_int(enabled)) + C.c_char_p(cheat_name.encode()), C.c_int(enabled)) if rval != M64ERR_SUCCESS: log.debug("cheat_enabled()") log.info("CoreCheatEnabled() failed for cheat code '%s'" % cheat_name) diff --git a/src/m64py/core/defs.py b/src/m64py/core/defs.py index ad70920..90234db 100644 --- a/src/m64py/core/defs.py +++ b/src/m64py/core/defs.py @@ -134,11 +134,11 @@ PLUGIN_ORDER = [ ] PLUGIN_NAME = { - M64PLUGIN_NULL: "NULL", - M64PLUGIN_RSP: "RSP", - M64PLUGIN_GFX: "Video", - M64PLUGIN_AUDIO: "Audio", - M64PLUGIN_INPUT: "Input" + M64PLUGIN_NULL: b"NULL", + M64PLUGIN_RSP: b"RSP", + M64PLUGIN_GFX: b"Video", + M64PLUGIN_AUDIO: b"Audio", + M64PLUGIN_INPUT: b"Input" } PLUGIN_DEFAULT = { diff --git a/src/m64py/core/vidext.py b/src/m64py/core/vidext.py index 7f1ca9d..02d8a4f 100644 --- a/src/m64py/core/vidext.py +++ b/src/m64py/core/vidext.py @@ -114,7 +114,7 @@ class Video(): def set_caption(self, title): """Sets the caption text of the emulator rendering window. """ - title = "M64Py :: %s" % title + title = "M64Py :: %s" % title.decode() self.parent.set_caption.emit(title) return M64ERR_SUCCESS @@ -127,11 +127,11 @@ class Video(): def gl_get_proc(self, proc): """Used to get a pointer to an OpenGL extension function.""" - addr = self.glcontext.getProcAddress(proc) + addr = self.glcontext.getProcAddress(proc.decode()) if addr is not None: return addr.__int__() else: - log.warn("VidExtFuncGLGetProc: '%s'" % proc) + log.warn("VidExtFuncGLGetProc: '%s'" % proc.decode()) def gl_set_attr(self, attr, value): """Sets OpenGL attributes.""" diff --git a/src/m64py/frontend/mainwindow.py b/src/m64py/frontend/mainwindow.py index bb6ed99..f5fcc9b 100644 --- a/src/m64py/frontend/mainwindow.py +++ b/src/m64py/frontend/mainwindow.py @@ -306,7 +306,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.glwidget.setFocus(True) if not self.cheats: self.cheats = Cheat(self) - self.update_status(self.worker.core.rom_settings.goodname) + self.update_status(self.worker.core.rom_settings.goodname.decode()) QTimer.singleShot(2000, self.worker.toggle_actions) def on_rom_closed(self): diff --git a/src/m64py/frontend/romlist.py b/src/m64py/frontend/romlist.py index 8e85146..c2983bc 100644 --- a/src/m64py/frontend/romlist.py +++ b/src/m64py/frontend/romlist.py @@ -91,8 +91,8 @@ class ROMList(QMainWindow, Ui_ROMList): for rom in self.rom_list: if len(rom) == 4: crc, goodname, path, fname = rom - list_item = QListWidgetItem(goodname) - list_item.setData(Qt.UserRole, (crc, goodname, path, fname)) + list_item = QListWidgetItem(goodname.decode()) + list_item.setData(Qt.UserRole, (crc, goodname.decode(), path, fname)) self.listWidget.addItem(list_item) self.progressBar.setValue(0) self.progressBar.hide()