Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. #From lib-python/3/test/_test_multiprocessing.py
  2. class _Foo(Structure):
  3.     _fields_ = [
  4.         ('x', c_int),
  5.         ('y', c_double)
  6.         ]
  7.  
  8. def test_copy(self):
  9.     foo = _Foo(2, 5.0)
  10.     bar = copy(foo)
  11.     foo.x = 0
  12.     foo.y = 0
  13.     self.assertEqual(bar.x, 2)
  14.     self.assertAlmostEqual(bar.y, 5.0)  
  15.  
  16. #This goes to the sharedctypes of multiprocessing
  17. def copy(obj):
  18.     new_obj = _new_value(type(obj))
  19.     ctypes.pointer(new_obj)[0] = obj
  20.     return new_obj
  21.  
  22. #Which then breaks here
  23. def __setitem__(self, index, value):
  24.    cobj = self._type_.from_param(value)
  25.    if ensure_objects(cobj) is not None:
  26.        store_reference(self, index, cobj._objects)
  27.    self._subarray(index)[0] = cobj._get_buffer_value()
  28.    #At this last line
  29.  
  30. The error:
  31.  
  32. ERROR: test_copy (test.test_multiprocessing_forkserver.WithProcessesTestSharedCTypes)
  33. ----------------------------------------------------------------------
  34. Traceback (most recent call last):
  35.   File "/extra1/home/buildslave/buildslave/pypy-c-app-level-linux-x86-64/build/lib-python/3/test/_test_multiprocessing.py", line 2876, in test_copy
  36.     bar = copy(foo)
  37.   File "/extra1/home/buildslave/buildslave/pypy-c-app-level-linux-x86-64/build/lib-python/3/multiprocessing/sharedctypes.py", line 99, in copy
  38.     ctypes.pointer(new_obj)[0] = obj
  39.   File "/extra1/home/buildslave/buildslave/pypy-c-app-level-linux-x86-64/build/lib_pypy/_ctypes/pointer.py", line 116, in __setitem__
  40.     self._subarray(index)[0] = cobj._get_buffer_value()
  41. TypeError: 'StructureInstance' object does not support item assignment
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement