Skip to content

Conversation

@cfarrow
Copy link

@cfarrow cfarrow commented Jun 30, 2017

This is #23 with working tests.

Fixes #2
Fixes #16
Closes #23

The fix looks good to me. Any other takers?

satra and others added 5 commits July 13, 2012 08:53
* upstream/master: (907 commits)
  MAINT: Remove unused file
  BUG: Fix validation of This traits.
  Return None rather than raising. This is what would have happened if we'd been initializing all the CTrait fields properly in the first place.
  Don't segfault when asked for the default value of a trait that doesn't have one.
  Update Python versions supported in docs.
  Restore Appveyor support for 2.7 and 3.4.
  Update appveyor to use run_with_env.cmd from https://github.com/ogrisel/python-appveyor-demo
  Experimental commit to see if we can get Appveyor support working for 3.5 and 3.6.
  Fix a misuse of the unittest.expectedFailure decorator.
  Add Python 3.5 and Python 3.6 for Appveyor builds.
  Add Python 3.6 to Travis matrix.
  Raise for bad Python versions in the setup script; add relevant Trove classifiers.
  Update travis-ci-requirements.
  Drop Python 3.3 from appveyor matrix.
  Drop 2.6 and 3.3 from Travis CI matrix.
  Document Python version requirements.
  Version number bump for 4.7 development.
  Fix bad classifier.
  Release 4.6.0!
  Minor changes to release statement.
  ...
self.trait_set( trait_change_notify = trait_change_notify, **state )
self._post_init_trait_listeners()
self.traits_init()
for attr, trait in inst_traits.iteritems():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cfarrow I notice that here we're calling add_trait after doing traits_init() and _post_init_trait_listeners(), but in the clone_traits block below, we're calling add_trait before those calls. Do you know whether there's a reason for the difference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the reason. I'll look into the potential consequences. At the very least I'll make it consistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the doc string, traits_init should be called at the end of __setstate__. In practice, I don't think it matters. It is a no-op by default. The only place I have found it defined in the traits source is in HasUniqueStrings.

In any case, I moved it after all the add_traits to be consistent with the existing documentation and the behavior in clone_traits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Chris. I also moved the _post_init_trait_listeners call, so that it's consistent with clone_traits.

# All the counts should be the same.
self.assertEqual(counts[warmup:-1], counts[warmup+1:])

def test_hastraits_pickle_deepcopy(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks as though this is a single test that tests both the pickling and the deepcopy behaviour in one. I think it should be split into two separate tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

@cfarrow
Copy link
Author

cfarrow commented Dec 21, 2018

Thanks for the feedback. I've addressed the comments.

@cfarrow
Copy link
Author

cfarrow commented Dec 21, 2018

Ah, python 3 test failures! I'm investigating.

@codecov-io
Copy link

codecov-io commented Dec 21, 2018

Codecov Report

Merging #373 into master will increase coverage by 0.29%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
+ Coverage   64.03%   64.32%   +0.29%     
==========================================
  Files          48       48              
  Lines        7373     7381       +8     
  Branches     1472     1474       +2     
==========================================
+ Hits         4721     4748      +27     
+ Misses       2212     2198      -14     
+ Partials      440      435       -5
Impacted Files Coverage Δ
traits/has_traits.py 67.9% <100%> (+0.43%) ⬆️
traits/trait_handlers.py 63.17% <0%> (+0.13%) ⬆️
traits/traits.py 60.19% <0%> (+0.19%) ⬆️
traits/trait_base.py 58.57% <0%> (+2.14%) ⬆️
traits/etsconfig/etsconfig.py 63.58% <0%> (+6.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6208f63...cd5c9ea. Read the comment docs.

@cfarrow
Copy link
Author

cfarrow commented Dec 21, 2018

Everything is working now.

@mdickinson
Copy link
Member

Waiting for CI, then merging.

@mdickinson
Copy link
Member

Random failure at egg-fetching stage with Appveyor; restarting the job ...

@mdickinson mdickinson merged commit eecc23d into master Dec 23, 2018
@mdickinson mdickinson deleted the fix/dynamictraits branch December 23, 2018 18:45
@mdickinson
Copy link
Member

Merged. Thanks, @cfarrow!

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 this pull request may close these issues.

dynamic traits lose type information/validation when pickled or copied Pickling or copying dynamic traits makes them loose their type and metadata.

4 participants