Skip to content

Conversation

@satra
Copy link
Contributor

@satra satra commented Jul 13, 2012

thanks to a pointer from @rkern, this might actually resolve the bugs listed in #2 and #16. however somebody with knowledge of traits should see if making this instance related changes creates other problems.

i didn't know where to add tests but the following test would fail currently and would get addressed by the changes in the pr.

def test_hastraits_pickle_deepcopy():
    from cPickle import dumps, loads
    from copy import deepcopy
    a = HasTraits()
    a.add_trait('foo', Int)
    a.foo = 1
    assign_a = lambda : setattr(a, 'foo', 'a')
    yield assert_raises, Exception, assign_a
    pkld_a = dumps(a)
    unpkld_a = loads(pkld_a)
    assign_a_again = lambda : setattr(unpkld_a, 'foo', 'a')
    yield assert_raises, Exception, assign_a_again
    copied_a = deepcopy(a)
    assign_a_again = lambda : setattr(copied_a, 'foo', 'a')
    yield assert_raises, Exception, assign_a_again

@dpinte
Copy link
Member

dpinte commented Mar 21, 2013

could you add your test to the test suite (e.g. in traits/tests/test_regression.py) ?

@satra
Copy link
Contributor Author

satra commented Mar 21, 2013

@dpinte - i'm not sure this is a clean fix - somebody with real knowledge of traits should take a look. this actually didn't work fully for me - it broke other things that i didn't have time track down.

* 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.
  ...
@satra
Copy link
Contributor Author

satra commented Feb 17, 2017

@dpinte - this is ancient but this bug still exists, adding a test.

@mdickinson
Copy link
Member

Thank you for this contribution! Your fix was slightly reworked in #373, which is now merged.

@satra
Copy link
Contributor Author

satra commented Dec 24, 2018

@mdickinson - thank you very much.

@mdickinson
Copy link
Member

Unfortunately, #373 had to be reverted (see the PR description for details). I'll re-open the relevant issues.

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.

3 participants