[BUG] transport/memory.py doesn't handle strings
Aaron Bentley
aaron.bentley at utoronto.ca
Wed Oct 19 07:17:41 BST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robey Pointer wrote:
>
> On 18 Oct 2005, at 17:39, Aaron Bentley wrote:
>
>>> Robert Collins wrote:
>>>
>>>> On Tue, 2005-10-18 at 16:45 -0500, John A Meinel wrote:
>>>>
>>>>> There are a couple of changes that should be made to the
>>>>> transport/memory.py implementation.
>>>>> First, most of the "put" functions can take either a file-like
>>>>> object, or
>>>>> a string. Which means that MemoryTransport.put() shouldn't just call
>>>>> read(), it should also check to see if it is already a string. (Either
>>>>> that, or we can change the api if you really prefer).
>>>>
>>>>
>>>> I think that the ambigious api is very strange. I'd much rather have
>>>> explict put_stream, put_string etc.
>>>
>>>
>>> I'd rather have put_iterable, because files are iterables of strings,
>>> but so are lists, and so are strings. So all of these have the same
>>> result:
>>>
>>> put_iterable('hello')
>>> put_iterable(['hel','lo'])
>>> put_iterable(StringIO('hello'))
>
>
> Wouldn't that first one be terribly inefficient though? :)
If it's short enough that it fits in a command parameter,
(Iterating
> a string gives you one byte at a time.)
>
> It also looks like iterating over a binary file gives you a single
> string with the entire contents of the file.
It shouldn't. Binary files usually have newline characters in them.
Yuck. :( My coworkers
> have been known to checkin 100+MB tarballs, and you don't want to load
> that all into memory at once.
We already do. Look at osutils.pumpfile.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDVeUF0F+nu1YWqI0RAoHfAJ9iiAshGYBSbdxYpm+FiA8mnsJYuQCfdmex
6jW+/Lte5xP5DkyhvXUz03E=
=2MAs
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list