Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#61393 closed defect (fixed)

TypeError: StringIO() argument 1 must be string or buffer, not None

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: neverpanic (Clemens Lang)
Priority: Normal Milestone:
Component: trac Version:
Keywords: Cc:
Port:

Description

This link produces a Trac error:

Oops…
Trac detected an internal error:
TypeError: StringIO() argument 1 must be string or buffer, not None
This is probably a local installation issue.

Change History (3)

comment:1 Changed 4 years ago by neverpanic (Clemens Lang)

Owner: changed from admin@… to neverpanic
Status: newaccepted

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.

comment:2 Changed 4 years ago by neverpanic (Clemens Lang)

Resolution: fixed
Status: acceptedclosed

See https://trac.edgewall.org/ticket/13327 for upstream report and patch.

I've backported the patch to our installation.

comment:3 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Great! Thank you.

Note: See TracTickets for help on using tickets.