title: How to add bytes to bytearray in Python 3.7?
body: <p>I am new the Python 3.7 and I am trying to read bytes from a serial port using the following code. I am using <code>pySerial</code> module and the <a href="https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.read" rel="noreferrer">read()</a> function returns <code>bytes</code>.    </p>
  
  <pre><code>self.uart = serial.Serial()
  self.uart.port = '/dev/tty/USB0'
  self.uart.baudrate = 115200
  self.uart.open()
  # buffer for received bytes
  packet_bytes = bytearray()
  # read and process data from serial port
  while True:
      # read single byte from serial port
      current_bytes = self._uart.read()
      if current_bytes is B'$':
          self.process_packet(packet_bytes)
          packet_bytes = bytearray()
      else:
          packet_bytes.append(current_bytes)        &lt;- Error occurs here
  </code></pre>
  
  <p>I receive the following error:</p>
  
  <blockquote>
    <p>TypeError: an integer is required</p>
  </blockquote>
  
  <p>Some idea how to solve?</p>