Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickling Theme errors on v7.0.0 #825

Closed
notmatthancock opened this issue May 15, 2020 · 2 comments · Fixed by #915
Closed

Pickling Theme errors on v7.0.0 #825

notmatthancock opened this issue May 15, 2020 · 2 comments · Fixed by #915
Assignees
Milestone

Comments

@notmatthancock
Copy link
Contributor

We recently upgraded traitsui: 6.1.3-5 --> 7.0.0-1. The following code fails on the newer version but runs fine on the older:

>>> import pickle
>>> from traitsui.theme import Theme
>>> theme = Theme()
>>> pickle.dumps(theme)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...traits/has_traits.py", line 1230, in __reduce_ex__
    return (__newobj__, (self.__class__,), self.__getstate__())
  File "...traits/has_traits.py", line 1194, in __getstate__
    result = self.trait_get(transient=is_none)
  File "...traits/has_traits.py", line 1298, in trait_get
    value = getattr(self, name, missing)
  File "...traitsui/theme.py", line 69, in _get_content_color
    import wx
ModuleNotFoundError: No module named 'wx'

Full context

We have a tree editor for which some nodes have color icons. The color nodes specifically fail to be draggable (into an IPython shell for example) because of the pickling failure above.

@corranwebster
Copy link
Contributor

I think the immediate fix for this is easy (fix the methods so they aren't wx-specific), but I'm also fairly comfortable saying that when a tree node is serialized for drag and drop, we shouldn't be accidentally getting a Theme object along for the ride. Can you give a little more context of your set up.

Also, Themes really, really, really need to die, but that's secondary.

@notmatthancock
Copy link
Contributor Author

Can you give a little more context of your set up.

Hmm. Besides the example above, I'm having a hard time reproducing this outside of our application.

Some more general notes:

  1. The occurs when dragging items out of a view with a tree editor, who has multiple custom tree nodes for various model types
  2. It only seems to occur for a tree node of a certain type, but I can't seem to associate a difference with the error
  3. We are not explicitly using anything from Theme

I need to investigate more along the lines of 2., but do not have the time at the moment.

@corranwebster corranwebster added this to the Release 7.0.1 milestone May 20, 2020
@ievacerny ievacerny self-assigned this Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants