Aug-05-2018, 09:18 AM
Hi members,
Does anyone know how to do a deep copy (copy.deepcopy) with pygame?
I'm having trouble performing a deep copy of an object (a class instance ?). The problem seems to stem from the fact that its Parent is from the pygame.sprite (but that's just a guess). I thought I would check here first because I think someone else must have come across this. Its advising me to use pygame to do this.
PS. I don't need to carry across any of the images in the copy operation.
Does anyone know how to do a deep copy (copy.deepcopy) with pygame?
I'm having trouble performing a deep copy of an object (a class instance ?). The problem seems to stem from the fact that its Parent is from the pygame.sprite (but that's just a guess). I thought I would check here first because I think someone else must have come across this. Its advising me to use pygame to do this.
PS. I don't need to carry across any of the images in the copy operation.
Error:Traceback (most recent call last):
File "/home/pi/Documents/Alan/Dev/RocksInSpace/Prototype/v0.10/Python/rocksinspace.py", line 2332, in <module>
TaskManager.process_task_list()
File "/home/pi/Documents/Alan/Dev/RocksInSpace/Prototype/v0.10/Python/clsTaskManager.py", line 102, in process_task_list
cls.process_task_queue(tl)
File "/home/pi/Documents/Alan/Dev/RocksInSpace/Prototype/v0.10/Python/clsTaskManager.py", line 120, in process_task_queue
q.linked_routine(q)
File "/home/pi/Documents/Alan/Dev/RocksInSpace/Prototype/v0.10/Python/clsAutopilot.py", line 95, in _autopilot_point_craft_in_oaf
self._autopilot_turn_to_angle(obj, update_task_status)
File "/home/pi/Documents/Alan/Dev/RocksInSpace/Prototype/v0.10/Python/clsAutopilot.py", line 269, in _autopilot_turn_to_angle
so_dupl =copy.deepcopy(so)
File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
state = deepcopy(state, memo)
File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
y = copier(x, memo)
File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python3.4/copy.py", line 295, in _reconstruct
y = callable(*args)
File "/usr/lib/python3.4/copyreg.py", line 88, in __newobj__
return cls.__new__(cls, *args)
TypeError: object.__new__(pygame.mask.Mask) is not safe, use pygame.mask.Mask.__new__()