diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index dc4fca43f7..dc74b64696 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -168,8 +168,8 @@ def cleanType(self, type_name: str) -> str: Handles translation of common C++ types to Python types, as well as a few specific wx types to Python types. """ - double_type = 'float' if PY3 else 'double' - long_type = 'int' if PY3 else 'long' + double_type = 'float' + long_type = 'int' type_map = { # Some types are guesses, marked with TODO to verify automatic # conversion actually happens. Also, these are the type-names diff --git a/wx/lib/agw/aui/auibar.py b/wx/lib/agw/aui/auibar.py index 8a59d8c7a2..84c80d17bd 100644 --- a/wx/lib/agw/aui/auibar.py +++ b/wx/lib/agw/aui/auibar.py @@ -65,7 +65,7 @@ def __init__(self, command_type, win_id): :param integer `win_id`: the window identification number. """ - if type(command_type) in int: + if isinstance(command_type, int): wx.PyCommandEvent.__init__(self, command_type, win_id) else: wx.PyCommandEvent.__init__(self, command_type.GetEventType(), command_type.GetId()) @@ -155,7 +155,7 @@ def __init__(self, command_type=None, win_id=0): CommandToolBarEvent.__init__(self, command_type, win_id) - if type(command_type) in int: + if isinstance(command_type, int): self.notify = wx.NotifyEvent(command_type, win_id) else: self.notify = wx.NotifyEvent(command_type.GetEventType(), command_type.GetId()) diff --git a/wx/lib/agw/aui/auibook.py b/wx/lib/agw/aui/auibook.py index 573cfd2242..28f1e19b34 100644 --- a/wx/lib/agw/aui/auibook.py +++ b/wx/lib/agw/aui/auibook.py @@ -391,7 +391,7 @@ def __init__(self, command_type=None, win_id=0): :param integer `win_id`: the window identification number. """ - if type(command_type) in int: + if isinstance(command_type, int): wx.PyCommandEvent.__init__(self, command_type, win_id) else: wx.PyCommandEvent.__init__(self, command_type.GetEventType(), command_type.GetId()) @@ -524,7 +524,7 @@ def __init__(self, command_type=None, win_id=0): CommandNotebookEvent.__init__(self, command_type, win_id) - if type(command_type) in int: + if isinstance(command_type, int): self.notify = wx.NotifyEvent(command_type, win_id) else: self.notify = wx.NotifyEvent(command_type.GetEventType(), command_type.GetId()) @@ -1173,7 +1173,7 @@ def SetActivePage(self, wndOrInt): :param `wndOrInt`: an instance of :class:`wx.Window` or an integer specifying a tab index. """ - if type(wndOrInt) in int: + if isinstance(wndOrInt, int): if wndOrInt >= len(self._pages): return False diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index c48926b20b..1ac41a3ab6 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -349,6 +349,8 @@ def __init__(self, parent): Latest Revision: Helio Guilherme @ 09 Aug 2018, 21.35 GMT +Version 2.7 + """ # Version Info diff --git a/wx/lib/agw/flatmenu.py b/wx/lib/agw/flatmenu.py index 9ff0e3ef85..92752b4400 100644 --- a/wx/lib/agw/flatmenu.py +++ b/wx/lib/agw/flatmenu.py @@ -197,6 +197,7 @@ def CreateMenu(self): import wx import os import math +import io import wx.lib.colourutils as colourutils diff --git a/wx/lib/agw/ultimatelistctrl.py b/wx/lib/agw/ultimatelistctrl.py index 1c12dd8f5b..91ba9b2d77 100644 --- a/wx/lib/agw/ultimatelistctrl.py +++ b/wx/lib/agw/ultimatelistctrl.py @@ -548,9 +548,6 @@ def __init__(self, parent): IL_FIXED_SIZE = 0 IL_VARIABLE_SIZE = 1 -# Python integers, to make long types to work with CreateListItem -INTEGER_TYPES = int - # ---------------------------------------------------------------------------- # Functions @@ -567,7 +564,7 @@ def to_list(input): if isinstance(input, list): return input - elif isinstance(input, INTEGER_TYPES): + elif isinstance(input, int): return [input] else: raise Exception("Invalid parameter passed to `to_list`: only integers and list are accepted.") @@ -595,7 +592,7 @@ def CreateListItem(itemOrId, col): :param `col`: the item column. """ - if type(itemOrId) in INTEGER_TYPES: + if isinstance(itemOrId, int): item = UltimateListItem() item._itemId = itemOrId item._col = col @@ -2285,7 +2282,7 @@ def __init__(self, commandTypeOrEvent=None, winid=0): :param `winid`: the event identifier. """ - if type(commandTypeOrEvent) in INTEGER_TYPES: + if isinstance(commandTypeOrEvent, int): wx.PyCommandEvent.__init__(self, commandTypeOrEvent, winid) @@ -2452,7 +2449,7 @@ def __init__(self, commandTypeOrEvent=None, winid=0): CommandListEvent.__init__(self, commandTypeOrEvent, winid) - if type(commandTypeOrEvent) in INTEGER_TYPES: + if isinstance(commandTypeOrEvent, int): self.notify = wx.NotifyEvent(commandTypeOrEvent, winid) else: self.notify = wx.NotifyEvent(commandTypeOrEvent.GetEventType(), commandTypeOrEvent.GetId()) diff --git a/wx/lib/agw/zoombar.py b/wx/lib/agw/zoombar.py index 144d042928..1a93969ea4 100644 --- a/wx/lib/agw/zoombar.py +++ b/wx/lib/agw/zoombar.py @@ -373,7 +373,7 @@ def __init__(self, parent, bitmap, disabledBmp=wx.NullBitmap, label=""): self._oldHeight = 0 self._vCenter = 0 self._hCenter = 0 - self._oldInc = -sys.MAXSIZE + self._oldInc = -sys.maxsize self._isSeparator = False self._enabled = True diff --git a/wx/lib/intctrl.py b/wx/lib/intctrl.py index 5cb9123fc4..3d5002bc89 100644 --- a/wx/lib/intctrl.py +++ b/wx/lib/intctrl.py @@ -45,7 +45,7 @@ #---------------------------------------------------------------------------- MAXSIZE = sys.maxsize # (constants should be in upper case) -MINSIZE = -sys.MAXSIZE-1 +MINSIZE = -sys.maxsize-1 LONGTYPE = int #---------------------------------------------------------------------------- @@ -697,7 +697,7 @@ def IsInBounds(self, value=None): value = self.GetValue() if( not (value is None and self.IsNoneAllowed()) - and type(value) not in int ): + and not isinstance(value, int) ): raise ValueError ( 'IntCtrl requires integer values, passed %s'% repr(value) ) @@ -809,7 +809,7 @@ def _toGUI( self, value ): elif type(value) == LONGTYPE and not self.IsLongAllowed(): raise ValueError ( 'IntCtrl requires integer value, passed long' ) - elif type(value) not in int: + elif not isinstance(value, int): raise ValueError ( 'IntCtrl requires integer value, passed %s'% repr(value) ) diff --git a/wx/lib/pubsub/core/kwargs/publisher.py b/wx/lib/pubsub/core/kwargs/publisher.py index bda42fc5ef..fbe2076f85 100644 --- a/wx/lib/pubsub/core/kwargs/publisher.py +++ b/wx/lib/pubsub/core/kwargs/publisher.py @@ -42,7 +42,7 @@ class SenderTooManyKwargs(RuntimeError): def __init__(self, kwargs, commonArgName): extra = kwargs.copy() del extra[commonArgName] - msg = 'Sender has too many kwargs (%s)' % ( extra.keys(),) + msg = 'Sender has too many kwargs (%s)' % ( list(extra.keys()),) RuntimeError.__init__(self, msg) class SenderWrongKwargName(RuntimeError): @@ -60,7 +60,7 @@ def sendMessage(self, _topicName, **kwarg): if len(kwarg) > 1: raise self.SenderTooManyKwargs(kwarg, commonArgName) elif len(kwarg) == 1 and commonArgName not in kwarg: - raise self.SenderWrongKwargName( kwarg.keys()[0], commonArgName) + raise self.SenderWrongKwargName( list(kwarg.keys())[0], commonArgName) data = kwarg.get(commonArgName, None) kwargs = { commonArgName: self.Msg( _topicName, data) } diff --git a/wx/lib/pubsub/core/kwargs/topicargspecimpl.py b/wx/lib/pubsub/core/kwargs/topicargspecimpl.py index ea9817f1e1..863baf8a59 100644 --- a/wx/lib/pubsub/core/kwargs/topicargspecimpl.py +++ b/wx/lib/pubsub/core/kwargs/topicargspecimpl.py @@ -114,14 +114,14 @@ def check(self, msgKwargs): hasReqd = (needReqd <= all) if not hasReqd: raise SenderMissingReqdMsgDataError( - self.topicNameTuple, msgKwargs.keys(), needReqd - all) + self.topicNameTuple, list(msgKwargs.keys()), needReqd - all) # check that all other args are among the optional spec optional = all - needReqd ok = (optional <= set(self.allOptional)) if not ok: raise SenderUnknownMsgDataError( self.topicNameTuple, - msgKwargs.keys(), optional - set(self.allOptional) ) + list(msgKwargs.keys()), optional - set(self.allOptional) ) def filterArgs(self, msgKwargs): """Returns a dict which contains only those items of msgKwargs diff --git a/wx/lib/pubsub/core/topicdefnprovider.py b/wx/lib/pubsub/core/topicdefnprovider.py index 6aca10fc51..b832710627 100644 --- a/wx/lib/pubsub/core/topicdefnprovider.py +++ b/wx/lib/pubsub/core/topicdefnprovider.py @@ -295,7 +295,7 @@ def doneIter(self): # remove the temporary module and its compiled version (*.pyc) os.remove(self.__filename) try: # py3.2+ uses special folder/filename for .pyc files - from imp import cache_from_source + from importlib.util import cache_from_source os.remove(cache_from_source(self.__filename)) except ImportError: os.remove(self.__filename + 'c') @@ -356,7 +356,7 @@ def getDefn(self, topicNameTuple): return desc, spec def topicNames(self): - return self.__topicDefns.keys() + return iter(self.__topicDefns.keys()) def getTreeDoc(self): return self.__treeDocs @@ -427,7 +427,7 @@ def exportTopicTreeSpec(moduleName = None, rootTopic=None, bak='bak', moduleDoc= if rootTopic is None: from .. import pub rootTopic = pub.getDefaultTopicMgr().getRootAllTopics() - elif isintance(rootTopic, str): + elif isinstance(rootTopic, str): from .. import pub rootTopic = pub.getDefaultTopicMgr().getTopic(rootTopic) diff --git a/wx/lib/pubsub/core/topicobj.py b/wx/lib/pubsub/core/topicobj.py index 5cfef56fc3..32c3f0e5b5 100644 --- a/wx/lib/pubsub/core/topicobj.py +++ b/wx/lib/pubsub/core/topicobj.py @@ -242,7 +242,7 @@ def getSubtopic(self, relName): def getSubtopics(self): """Get a list of Topic instances that are subtopics of self.""" - return self.__subTopics.values() + return list(self.__subTopics.values()) def getNumListeners(self): """Return number of listeners currently subscribed to topic. This is @@ -262,12 +262,12 @@ def hasListeners(self): def getListeners(self): """Get a copy of list of listeners subscribed to this topic. Safe to iterate over while listeners get un/subscribed from this topics (such as while sending a message).""" - return self.__listeners.keys() + return list(self.__listeners.keys()) def getListenersIter(self): """Get an iterator over listeners subscribed to this topic. Do not use if listeners can be un/subscribed while iterating. """ - return self.__listeners.keys() + return iter(self.__listeners.keys()) def validate(self, listener): """Checks whether listener could be subscribed to this topic: @@ -337,11 +337,11 @@ def unsubscribeAllListeners(self, filter=None): if filter is None: for listener in self.__listeners: listener._unlinkFromTopic_() - unsubd = self.__listeners.keys() + unsubd = list(self.__listeners.keys()) self.__listeners = {} else: unsubd = [] - for listener in self.__listeners.keys(): + for listener in list(self.__listeners.keys()): if filter(listener): unsubd.append(listener) listener._unlinkFromTopic_() diff --git a/wx/lib/pubsub/utils/xmltopicdefnprovider.py b/wx/lib/pubsub/utils/xmltopicdefnprovider.py index bca65d1696..48f49e2433 100644 --- a/wx/lib/pubsub/utils/xmltopicdefnprovider.py +++ b/wx/lib/pubsub/utils/xmltopicdefnprovider.py @@ -159,7 +159,7 @@ def getDefn(self, topicNameTuple): return self._topics.get(topicNameTuple, (None, None)) def topicNames(self): - return self._topics.keys() + return iter(self._topics.keys()) def getTreeDoc(self): return self._treeDoc @@ -256,7 +256,7 @@ def exportTopicTreeSpecXml(moduleName=None, rootTopic=None, bak='bak', moduleDoc if rootTopic is None: from .. import pub rootTopic = pub.getDefaultTopicTreeRoot() - elif isintance(rootTopic, str): + elif isinstance(rootTopic, str): from .. import pub rootTopic = pub.getTopic(rootTopic)