[BUG] transport/memory.py doesn't handle strings

John Arbash Meinel john at arbash-meinel.com
Sun Oct 23 15:22:05 BST 2005


Robert Collins wrote:
> On Wed, 2005-10-19 at 01:49 -0400, Aaron Bentley wrote:
> 
> 
>>Yeah, but
>>for f in 'hello':
>>    outf.write(f)
>>
>>has the same results as
>>
>>for f in ['hel', 'lo']:
>>    outf.write(f)
>>
>>has the same results as
>>
>>for f in StringIO('hello'):
>>    outf.write(f)
> 
> 
> Not if its too a file system with non trivial overhead per write.
> 
> And if the layer doing the write wants to optimise, then with a file
> object it is just:
> for data in source.read(buffer_limit):
>     outf.write(data)
> 
> If you have something that has fairly random behaviour, you have to
> manually manage the data to create good sized blocks.
> 
> 
>>In all cases, when you're done looping, you've written 'hello' to outf.
>> The number of steps it takes isn't hugely relevant.
> 
> 
> Well, see above.
> 
> 
>>It looked fine last I checked.  It was iterating up to the root, and
>>stopping there.  If you substituted transport('a') for transport('..')
>>in that loop, I'd expect it to be infinite.
> 
> 
> I think we should modify transport so that
> 'LocalTransport('/').clone('..') raises an exception.

That is a valid way of doing it, which I considered. I just know that
ordinary practice of "cd /; cd .." is perfectly valid, and leaves you in
the root directory.

Which meant that I wouldn't get an exception by default, and so I would
have to do a string check against whether or not I was at the root for
every clone. Not a big deal.

I usually avoid using exceptions as return values, but it isn't terrible.

John
=:->

> 
> Rob
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051023/34ff3cdb/attachment.pgp 


More information about the bazaar mailing list