diff --git a/apptools/persistence/state_pickler.py b/apptools/persistence/state_pickler.py index fb82746f4..01ac670a7 100644 --- a/apptools/persistence/state_pickler.py +++ b/apptools/persistence/state_pickler.py @@ -215,7 +215,7 @@ class StatePickler: will return the dictionary that is pickled. The format of the state dict is quite strightfoward. Basic types - (bool, int, long, float, complex, None, string and unicode) are + (bool, int, long, float, complex, None, string) are represented as they are. Everything else is stored as a dictionary containing metadata information on the object's type etc. and also the actual object in the 'data' key. For example:: @@ -268,9 +268,6 @@ def __init__(self): NumpyArrayType: self._do_numeric, State: self._do_state, } - if PY_VER == 2: - type_map[long] = self._do_basic_type - type_map[unicode] = self._do_basic_type self.type_map = type_map def dump(self, value, file): diff --git a/apptools/persistence/tests/test_state_pickler.py b/apptools/persistence/tests/test_state_pickler.py index 76805e829..694979471 100644 --- a/apptools/persistence/tests/test_state_pickler.py +++ b/apptools/persistence/tests/test_state_pickler.py @@ -15,7 +15,7 @@ import numpy from traits.api import Bool, Int, Array, Float, Complex, Any, \ - Str, Unicode, Instance, Tuple, List, Dict, HasTraits + Str, Instance, Tuple, List, Dict, HasTraits try: from tvtk.api import tvtk @@ -69,7 +69,7 @@ class TestTraits(HasTraits): c = Complex(complex(1.01234, 2.3)) n = Any s = Str('String') - u = Unicode(u'Unicode') + u = Str(u'Unicode') inst = Instance(A) tuple = Tuple list = List diff --git a/apptools/preferences/preference_binding.py b/apptools/preferences/preference_binding.py index 286616a4a..6dfd150d8 100644 --- a/apptools/preferences/preference_binding.py +++ b/apptools/preferences/preference_binding.py @@ -3,7 +3,7 @@ # Enthought library imports. from traits.api import Any, HasTraits, Instance, Str, Undefined -from traits.api import Unicode +from traits.api import Str # Third-party librart imports. import six @@ -102,8 +102,8 @@ def _get_value(self, trait_name, value): if type(handler) is Str: pass - # If the trait type is 'Unicode' then we convert the raw value. - elif type(handler) is Unicode: + # If the trait type is 'Str' then we convert the raw value. + elif type(handler) is Str: value = six.text_type(value) # Otherwise, we eval it! diff --git a/apptools/preferences/preferences_helper.py b/apptools/preferences/preferences_helper.py index 2b83e6699..4967c9f00 100644 --- a/apptools/preferences/preferences_helper.py +++ b/apptools/preferences/preferences_helper.py @@ -5,7 +5,7 @@ import logging # Enthought library imports. -from traits.api import HasTraits, Instance, Str, Unicode +from traits.api import HasTraits, Instance, Str # Local imports. from .i_preferences import IPreferences @@ -128,8 +128,8 @@ def _get_value(self, trait_name, value): trait = self.trait(trait_name) handler = trait.handler - # If the trait type is 'Str' or Unicode then we just take the raw value. - if isinstance(handler, (Str, Unicode)) or trait.is_str: + # If the trait type is 'Str' then we just take the raw value. + if isinstance(handler, Str) or trait.is_str: pass # Otherwise, we eval it! diff --git a/apptools/preferences/tests/test_preferences_helper.py b/apptools/preferences/tests/test_preferences_helper.py index 529c1fbdd..72037e46b 100644 --- a/apptools/preferences/tests/test_preferences_helper.py +++ b/apptools/preferences/tests/test_preferences_helper.py @@ -15,7 +15,7 @@ from apptools.preferences.api import Preferences, PreferencesHelper from apptools.preferences.api import ScopedPreferences from apptools.preferences.api import set_default_preferences -from traits.api import Any, Bool, HasTraits, Int, Float, List, Str, Unicode +from traits.api import Any, Bool, HasTraits, Int, Float, List, Str def width_listener(obj, trait_name, old, new): @@ -86,7 +86,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int ratio = Float visible = Bool - description = Unicode + description = Str offsets = List(Int) names = List(Str) @@ -138,7 +138,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int ratio = Float visible = Bool - description = Unicode + description = Str offsets = List(Int) names = List(Str) @@ -192,7 +192,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int(50) ratio = Float(1.0) visible = Bool(True) - description = Unicode(u'description') + description = Str(u'description') offsets = List(Int, [1, 2, 3, 4]) names = List(Str, ['joe', 'fred', 'jane']) @@ -224,7 +224,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int(50) ratio = Float(1.0) visible = Bool(True) - description = Unicode(u'') + description = Str(u'') offsets = List(Int, [1, 2, 3, 4]) names = List(Str, ['joe', 'fred', 'jane']) @@ -269,7 +269,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int ratio = Float visible = Bool - description = Unicode + description = Str offsets = List(Int) names = List(Str) @@ -301,7 +301,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int ratio = Float visible = Bool - description = Unicode + description = Str offsets = List(Int) names = List(Str) @@ -414,7 +414,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int ratio = Float visible = Bool - description = Unicode + description = Str offsets = List(Int) names = List(Str) @@ -478,7 +478,7 @@ class AcmeUIPreferencesHelper(PreferencesHelper): width = Int ratio = Float visible = Bool - description = Unicode + description = Str offsets = List(Int) names = List(Str) diff --git a/apptools/scripting/recorder.py b/apptools/scripting/recorder.py index 36eb1bdaa..de99da802 100644 --- a/apptools/scripting/recorder.py +++ b/apptools/scripting/recorder.py @@ -15,7 +15,7 @@ import six.moves.builtins from traits.api import (HasTraits, List, Str, Dict, Bool, - Unicode, Property, Int, Instance) + Property, Int, Instance) from traits.util.camel_case import camel_case_to_python @@ -101,7 +101,7 @@ class Recorder(HasTraits): # The Python script we have recorded so far. This is just a # convenience trait for the `get_code()` method. - script = Property(Unicode) + script = Property(Str) ######################################## # Private traits. diff --git a/apptools/undo/abstract_command.py b/apptools/undo/abstract_command.py index 90818a7e3..6f7d12ad1 100644 --- a/apptools/undo/abstract_command.py +++ b/apptools/undo/abstract_command.py @@ -13,7 +13,7 @@ #------------------------------------------------------------------------------ # Enthought library imports. -from traits.api import Any, HasTraits, Unicode, provides +from traits.api import Any, HasTraits, Str, provides # Local imports. from .i_command import ICommand @@ -33,7 +33,7 @@ class AbstractCommand(HasTraits): # This is the name of the command as it will appear in any GUI element. It # may include '&' which will be automatically removed whenever it is # inappropriate. - name = Unicode + name = Str ########################################################################### # 'ICommand' interface. diff --git a/apptools/undo/command_stack.py b/apptools/undo/command_stack.py index 6e6270c14..a967140f1 100644 --- a/apptools/undo/command_stack.py +++ b/apptools/undo/command_stack.py @@ -14,7 +14,7 @@ # Enthought library imports. from traits.api import Bool, HasTraits, Instance, Int, List, Property, \ - Unicode, provides + Str, provides # Local imports. from .abstract_command import AbstractCommand @@ -99,7 +99,7 @@ class CommandStack(HasTraits): # This is the name of the command that can be redone. It will be empty if # there is no command that can be redone. It is maintained by the undo # stack. - redo_name = Property(Unicode) + redo_name = Property(Str) # This is the undo manager that manages this stack. undo_manager = Instance(IUndoManager) @@ -107,7 +107,7 @@ class CommandStack(HasTraits): # This is the name of the command that can be undone. It will be empty if # there is no command that can be undone. It is maintained by the undo # stack. - undo_name = Property(Unicode) + undo_name = Property(Str) #### Private interface #################################################### diff --git a/apptools/undo/i_command.py b/apptools/undo/i_command.py index 7adb7ac5b..e3830cffd 100644 --- a/apptools/undo/i_command.py +++ b/apptools/undo/i_command.py @@ -14,7 +14,7 @@ # Enthought library imports. -from traits.api import Any, Interface, Unicode +from traits.api import Any, Interface, Str class ICommand(Interface): @@ -31,7 +31,7 @@ class ICommand(Interface): # This is the name of the command as it will appear in any GUI element. It # may include '&' which will be automatically removed whenever it is # inappropriate. - name = Unicode + name = Str ########################################################################### # 'ICommand' interface. diff --git a/apptools/undo/i_command_stack.py b/apptools/undo/i_command_stack.py index 9fb6c7310..acbed3461 100644 --- a/apptools/undo/i_command_stack.py +++ b/apptools/undo/i_command_stack.py @@ -13,7 +13,7 @@ #------------------------------------------------------------------------------ # Enthought library imports. -from traits.api import Bool, Instance, Interface, Unicode +from traits.api import Bool, Instance, Interface, Str # Local imports. from .i_undo_manager import IUndoManager @@ -36,7 +36,7 @@ class ICommandStack(Interface): # This is the name of the command that can be redone. It will be empty if # there is no command that can be redone. It is maintained by the undo # stack. - redo_name = Unicode + redo_name = Str # This is the undo manager that manages this stack. undo_manager = Instance(IUndoManager) @@ -44,7 +44,7 @@ class ICommandStack(Interface): # This is the name of the command that can be undone. It will be empty if # there is no command that can be undone. It is maintained by the undo # stack. - undo_name = Unicode + undo_name = Str ########################################################################### # 'ICommandStack' interface. diff --git a/apptools/undo/i_undo_manager.py b/apptools/undo/i_undo_manager.py index 27636a980..750ca13f6 100644 --- a/apptools/undo/i_undo_manager.py +++ b/apptools/undo/i_undo_manager.py @@ -13,7 +13,7 @@ #------------------------------------------------------------------------------ # Enthought library imports. -from traits.api import Bool, Event, Instance, Int, Interface, Unicode +from traits.api import Bool, Event, Instance, Int, Interface, Str class IUndoManager(Interface): @@ -36,7 +36,7 @@ class IUndoManager(Interface): # This is the name of the command that can be redone. It will be empty if # there is no command that can be redone. It is maintained by the undo # manager. - redo_name = Unicode + redo_name = Str # This is the sequence number of the next command to be performed. It is # incremented immediately before a command is invoked (by its 'do()' @@ -50,7 +50,7 @@ class IUndoManager(Interface): # This is the name of the command that can be undone. It will be empty if # there is no command that can be undone. It is maintained by the undo # manager. - undo_name = Unicode + undo_name = Str ########################################################################### # 'IUndoManager' interface. diff --git a/apptools/undo/undo_manager.py b/apptools/undo/undo_manager.py index fb09d10c8..2388d7f62 100644 --- a/apptools/undo/undo_manager.py +++ b/apptools/undo/undo_manager.py @@ -14,7 +14,7 @@ # Enthought library imports. from traits.api import Bool, Event, HasTraits, Instance, Int, Property, \ - Unicode, provides + Str, provides # Local imports. from .i_undo_manager import IUndoManager @@ -40,7 +40,7 @@ class UndoManager(HasTraits): # This is the name of the command that can be redone. It will be empty if # there is no command that can be redone. It is maintained by the undo # manager. - redo_name = Property(Unicode) + redo_name = Property(Str) # This is the sequence number of the next command to be performed. It is # incremented immediately before a command is invoked (by its 'do()' @@ -55,7 +55,7 @@ class UndoManager(HasTraits): # This is the name of the command that can be undone. It will be empty if # there is no command that can be undone. It is maintained by the undo # manager. - undo_name = Property(Unicode) + undo_name = Property(Str) ########################################################################### # 'IUndoManager' interface. diff --git a/docs/source/undo/Introduction.rst b/docs/source/undo/Introduction.rst index d182f862d..89dee28d6 100644 --- a/docs/source/undo/Introduction.rst +++ b/docs/source/undo/Introduction.rst @@ -103,12 +103,12 @@ interface. be the currently active stack. ``undo_name`` - This Unicode trait is the name of the command that can be undone, and will + This Str trait is the name of the command that can be undone, and will be empty if there is no such command. It is maintained by the undo manager. ``redo_name`` - This Unicode trait is the name of the command that can be redone, and will + This Str trait is the name of the command that can be redone, and will be empty if there is no such command. It is maintained by the undo manager. @@ -143,12 +143,12 @@ The ``CommandStack`` class is the default implementation of the data is saved to disk for example). ``undo_name`` - This Unicode trait is the name of the command that can be undone, and will + This Str trait is the name of the command that can be undone, and will be empty if there is no such command. It is maintained by the command stack. ``redo_name`` - This Unicode trait is the name of the command that can be redone, and will + This Str trait is the name of the command that can be redone, and will be empty if there is no such command. It is maintained by the command stack. @@ -199,7 +199,7 @@ any undoable/redoable command. operates on. It is not used by the framework itself. ``name`` - This Unicode trait is the name of the command as it will appear in any GUI + This Str trait is the name of the command as it will appear in any GUI element (e.g. in the text of an undo and redo menu entry). It may include ``&`` to indicate a keyboard shortcut which will be automatically removed whenever it is inappropriate. diff --git a/examples/undo/commands.py b/examples/undo/commands.py index 1254a3ddc..f06bfc7bf 100644 --- a/examples/undo/commands.py +++ b/examples/undo/commands.py @@ -14,7 +14,7 @@ # Enthought library imports. -from traits.api import Instance, Int, Unicode +from traits.api import Instance, Int, Str from apptools.undo.api import AbstractCommand # Local imports. @@ -33,7 +33,7 @@ class LabelIncrementSizeCommand(AbstractCommand): data = Instance(Label) # The name of the command. - name = Unicode("&Increment size") + name = Str("&Increment size") #### Private interface #################################################### @@ -76,7 +76,7 @@ class LabelDecrementSizeCommand(AbstractCommand): data = Instance(Label) # The name of the command. - name = Unicode("&Decrement size") + name = Str("&Decrement size") #### Private interface #################################################### @@ -118,7 +118,7 @@ class LabelNormalFontCommand(AbstractCommand): data = Instance(Label) # The name of the command. - name = Unicode("&Normal font") + name = Str("&Normal font") ########################################################################### # 'ICommand' interface. @@ -150,7 +150,7 @@ class LabelBoldFontCommand(AbstractCommand): data = Instance(Label) # The name of the command. - name = Unicode("&Bold font") + name = Str("&Bold font") ########################################################################### # 'ICommand' interface. @@ -182,7 +182,7 @@ class LabelItalicFontCommand(AbstractCommand): data = Instance(Label) # The name of the command. - name = Unicode("&Italic font") + name = Str("&Italic font") ########################################################################### # 'ICommand' interface. diff --git a/examples/undo/model.py b/examples/undo/model.py index 2eee15beb..03d0476dd 100644 --- a/examples/undo/model.py +++ b/examples/undo/model.py @@ -14,7 +14,7 @@ # Enthought library imports. -from traits.api import Enum, HasTraits, Int, Unicode +from traits.api import Enum, HasTraits, Int, Str class Label(HasTraits): @@ -23,7 +23,7 @@ class Label(HasTraits): #### 'Label' interface #################################################### # The name. - name = Unicode + name = Str # The size in points. size = Int(18)