subversion-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenneth Porter <>
Subject Re: commit says TypeError: must be unicode, not str
Date Thu, 01 Feb 2018 03:23:59 GMT
--On Tuesday, January 23, 2018 7:14 AM -0800 Kenneth Porter 
<> wrote:

>    File "/usr/lib64/python2.7/site-packages/svn/", line 87, in
> _dump_contents
>      fp.write(chunk)
> TypeError: must be unicode, not str

Here's the code where this is going wrong. I think svn_stream_read is 
returning a byte stream and the file object here is expecting a unicode 
string. Is there a missing decode('utf-8') call? (I'm a very new Python 
coder but have lots of experience in C++ and some understanding of unicode.)

Package is subversion-python-1.7.14-11.el7_4.x86_64 in CentOS 7.4.

>From /usr/lib64/python2.7/site-packages/svn/

  def _dump_contents(self, file, root, path, pool=None):
    fp =, 'w+') # avoid namespace clash with
                                   # trimmed-down svn_fs_open()
    if path is not None:
      stream = file_contents(root, path, pool)
        while True:
          chunk = _svncore.svn_stream_read(stream, 
          if not chunk:

BTW, I found this nice treatment of unicode in Python 2 and 3:


View raw message