I have a class, shown below, that inherits from datetime.date
class my_class(datetime.date):
def __new__(cls, arg1=None):
print ("arg1: ", arg1)
return super().__new__(cls, 2015, 11, 2)
When I copy (or deepcopy) an instance of this class, as shown below,
import copy
my_obj = my_class(5)
copy.copy(my_obj)
I get the following output
arg1: 5
arg1: b'\x07\xdf\x0b\x02'
So clearly some bytes object is passed as the first argument when doing a copy (or deepcopy). I know that the copy function works by passing arguments to the constructor of the object in question such that an identical object will be created...so why is it passing these bytes objects?
This behaviour seems to occur only when inheriting from immutable objects, since when I tested this when inheriting from a list object, the copy function did not pass a bytes object.
(Note that the class I defined above is a very (very!) simplified case of a real class I am using, that also inherits from datetime.date)
Thanks in advance
NOTE
I am using Python 3.5.1