title: Subprocess.Popen process.communicate() function error
body: <p>I tried this <a href="https://stackoverflow.com/questions/14286418/is-there-a-way-to-create-a-new-p4-changelist-using-python-subprocess">solution answer</a> to solve my problem but when using the solution I got this error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;version_build.py&quot;, line 125, in &lt;module&gt;
      if __name__=='__main__': main()
    File &quot;version_build.py&quot;, line 113, in main
      change = p4change(p4)
    File &quot;version_build.py&quot;, line 90, in p4change
      change = p.communicate(changespec)[0]
    File &quot;C:\Python36\Lib\subprocess.py&quot;, line 843, in communicate
      stdout, stderr = self._communicate(input, endtime, timeout)
    File &quot;C:\Python36\Lib\subprocess.py&quot;, line 1086, in _communicate
      self._stdin_write(input)
    File &quot;C:\Python36\Lib\subprocess.py&quot;, line 781, in _stdin_write
      self.stdin.write(input)
  TypeError: a bytes-like object is required, not 'str'
  </code></pre>
  <p><strong>My main question is:</strong> Why am I getting this error, am I missing something from the solution given to the other question?</p>
  <p>I am using python3.
  I have tried to use the str.encode() function, but when printing out the variable to the console, it is blank. <code>b''</code></p>
  <p>Here are the lines it is failing on (mainly the p.communicate line):</p>
  <pre><code>    changespec = 'change: new\n' + description
      
      p = subprocess.Popen([p4, 'change', '-i'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
      change = p.communicate(changespec)[0]
      return change
  </code></pre>