derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

copy.copy(sentinel.foo) is not sentinel.foo #244

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. import mock, copy
2. copy.copy(sentinel.foo) is sentinel.foo -> False

What is the expected output? What do you see instead?
I would expect sentinels to not be copied; they are meant to be singletons.

What version of the product are you using? On what operating system?
Ubuntu 14.10, python-mock 1.0.1-3
I also tested it on trunk.

Please provide any additional information below.
In MAAS we have the following snippet in an early import to solve the problem:

  # Make sure that sentinel objects are not copied.
  sentinel_type = type(mock.sentinel.foo)
  copy._copy_dispatch[sentinel_type] = copy._copy_immutable
  copy._deepcopy_dispatch[sentinel_type] = copy._copy_immutable

Original issue reported on code.google.com by gavinpan...@gmail.com on 22 Jan 2015 at 11:33