[MacPorts] #61393: TypeError: StringIO() argument 1 must be string or buffer, not None

MacPorts noreply at macports.org
Tue Nov 3 21:55:48 UTC 2020


#61393: TypeError: StringIO() argument 1 must be string or buffer, not None
-------------------------+------------------------
  Reporter:  ryandesign  |      Owner:  neverpanic
      Type:  defect      |     Status:  accepted
  Priority:  Normal      |  Milestone:
 Component:  trac        |    Version:
Resolution:              |   Keywords:
      Port:              |
-------------------------+------------------------
Changes (by neverpanic):

 * status:  new => accepted
 * owner:  admin@… => neverpanic


Comment:

 Can reproduce. This is a bug in Trac that happens at
 https://trac.edgewall.org/browser/trunk/tracopt/versioncontrol/git/PyGIT.py#L693.

 To read the contents of a file, Trac spawns a `git cat-file --batch`
 process, and repeatedly writes a tree identifer (obtained using `git ls-
 tree -zl $revision -- $path`) to stdin of that process. The answer is a
 line with that same hash, the type of object, and its size. It then
 proceeds to read that number of bytes from the socket.

 However, if the file is larger than 65535 bytes (which portconfigure.tcl
 is with 72044 bytes) the `self.__cat_file_pipe.stdout.read()` call can and
 will return fewer bytes than the size passed to `read()`. This is
 expected, because the operating system will buffer data written into a
 pipe and block the writing process. Trac should handle this situation and
 continue to read until the expected size is reached, but does not do so.
 The next attempt to read a file then fails, because the next line to be
 read from the stream is not the tuple of (hash, type, size), but a line
 from the contents of the last file that was read, which cannot be parsed
 correctly and causes a `None` return value, which then gets passed to the
 constructor of `StringIO()`, and that's the error you see.

 I'll file that with trac upstream and submit a patch.

-- 
Ticket URL: <https://trac.macports.org/ticket/61393#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list