/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/memory.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-29 08:46:23 UTC
  • mto: (2018.18.6 hpss-faster-copy)
  • mto: This revision was merged to the branch mainline in revision 2435.
  • Revision ID: andrew.bennetts@canonical.com-20070329084623-ruqx0po8q3lxw0b7
Be strict about unicode passed to transport.put_{bytes,file} and SmartClient.call_with_body_bytes, fixing part of TestLockableFiles_RemoteLockDir.test_read_write.

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
        """See Transport.put_file()."""
129
129
        _abspath = self._abspath(relpath)
130
130
        self._check_parent(_abspath)
131
 
        self._files[_abspath] = (f.read(), mode)
 
131
        bytes = f.read()
 
132
        if type(bytes) is not str:
 
133
            # Although not strictly correct, we raise UnicodeEncodeError to be
 
134
            # compatible with other transports.
 
135
            raise UnicodeEncodeError(
 
136
                'undefined', bytes, 0, 1,
 
137
                'put_file must be given a file of bytes, not unicode.')
 
138
        self._files[_abspath] = (bytes, mode)
132
139
 
133
140
    def mkdir(self, relpath, mode=None):
134
141
        """See Transport.mkdir()."""