[issue27651] bytearray changes when function mutates it

SilentGhost report at bugs.python.org
Sat Jul 30 06:20:15 EDT 2016


SilentGhost added the comment:

bytearray is a mutable object and the behaviour is compatible with behaviour of any mutable object in Python. You're passing a into the yuke_bpe function and the original object is being modified (emptied) there. To work around this you could copy the object within the functioin and carry out transformations on the copied object.

----------
nosy: +SilentGhost
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
title: About bytearray -> bytearray changes when function mutates it
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27651>
_______________________________________


More information about the Python-bugs-list mailing list