Python copy function passing 'bytes' object as first argument
<p>I have a class, shown below, that inherits from <code>datetime.date</code></p>

<pre><code>class my_class(datetime.date):
    def __new__(cls, arg1=None):
        print ("arg1: ", arg1)
        return super().__new__(cls, 2015, 11, 2)
</code></pre>

<p>When I <code>copy</code> (or <code>deepcopy</code>) an instance of this class, as shown below,</p>

<pre><code>import copy
my_obj = my_class(5)
copy.copy(my_obj)
</code></pre>

<p>I get the following output</p>

<pre><code>arg1:  5
arg1:  b'\x07\xdf\x0b\x02'
</code></pre>

<p>So clearly some <code>bytes</code> object is passed as the first argument when doing a <code>copy</code> (or <code>deepcopy</code>). I know that the <code>copy</code> 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 <code>bytes</code> objects?</p>

<p>This behaviour seems to occur only when inheriting from immutable objects, since when I tested this when inheriting from a <code>list</code> object, the <code>copy</code> function did not pass a <code>bytes</code> object.</p>

<p>(Note that the class I defined above is a very (very!) simplified case of a real class I am using, that also inherits from <code>datetime.date</code>)</p>

<p>Thanks in advance</p>

<p><strong>NOTE</strong></p>

<p>I am using Python 3.5.1</p>