title: "TypeError: string argument without an encoding", but the string is encoded?
body: <p>I am working on converting an <a href="https://github.com/kabniel/last2libre/blob/master/scrobble.py#L34" rel="noreferrer">existing program</a> from Python2 to Python3. One of the methods in the program authenticates the user with a remote server. It will prompt the user to enter in a password.</p>
  
  <pre><code>def _handshake(self):
      timestamp = int(time.time())
      token = (md5hash(md5hash((self.password).encode('utf-8')).hexdigest()
                  + str(bytes('timestamp').encode('utf-8'))))
      auth_url = "%s/?hs=true&amp;p=1.2&amp;u=%s&amp;t=%d&amp;a=%s&amp;c=%s" % (self.name,
                                                            self.username,
                                                            timestamp,
                                                            token,
                                                            self.client_code)
      response = urlopen(auth_url).read()
      lines = response.split("\n")
      if lines[0] != "OK":
          raise ScrobbleException("Server returned: %s" % (response,))
      self.session_id = lines[1]
      self.submit_url = lines[3]
  </code></pre>
  
  <p>The problem with this method is that after the integer is converted to a string, it needs to be encoded. But as far as I can tell, it is already encoded? I found <a href="https://stackoverflow.com/questions/31161243/python-string-argument-without-an-encoding">this question</a> but I was having a hard time applying that to the context of this program.</p>
  
  <p>This is the line giving me problems.</p>
  
  <ul>
  <li><code>+ str(bytes('timestamp').encode('utf-8'))))</code>
  
  <ul>
  <li><code>TypeError: string argument without an encoding</code></li>
  </ul></li>
  </ul>
  
  <p>I have tried playing around with alternate ways of doing this, all with varying types of errors.</p>
  
  <ul>
  <li><code>+ str(bytes('timestamp', 'utf-8'))))</code>
  
  <ul>
  <li><code>TypeError: Unicode-objects must be encoded before hashing</code></li>
  </ul></li>
  <li><code>+ str('timestamp', 'utf-8')))</code>
  
  <ul>
  <li><code>TypeError: decoding str is not supported</code></li>
  </ul></li>
  </ul>
  
  <p>I'm still getting started learning Python (but I have beginner to intermediate knowledge of Java), so I am not completely familiar with the language yet. Does anyone have any thoughts on what this issue might be?</p>
  
  <p>Thanks!</p>