Re: Re: UnicodeDecodeError

Toby Dickenson <[email protected]> Fri, 9 Dec 2005 11:44:55 +0000
Newsgroups gmane.comp.web.zope.zodb.dirstorage
Message-ID <[email protected]>
On Friday 09 December 2005 11:18, Philipp von Weitershausen wrote:

> I have no explanation why there's a difference in behaviour on
> FileStorage and DirStorage if their assumptions on the input seem to be
> the same. I'll try to investigate further.

Aha, there is a difference. But it is the inverse of what I was originally 
looking for.....

FileStorage converts the inputs to plain string objects using str(), but 
DirectoryStorage does not.

This makes a difference if one of these inputs was a unicode string object 
containing ascii content, for example u"abc". FileStorage happily converts 
that to "abc". However DirectoryStorage will try to concatenate the unicode 
original with the binary pickle. This causes python to try to convert the 
binary pickle to unicode, causing an exception because there are bytes is the 
pickle outside the ascii range.

So, to get DirectoryStorage behaving the same as FileStorage we could add:

    u = str(u)
    d = str(d)

> Right. Zope 3 is wrong here. Either the choice of principal IDs being
> unicode is correct, in which case it must make sure to only pass an
> 8byte string to the transaction, or we should revise Zope 3's choice of
> using unicode for principal IDs.
> 
> I will bring this up among the Zope 3 developers by creating a collector
> issue.
> 
> Philipp
> 

-- 
Toby Dickenson

____________________

Important Notice:

This email and any attachments are confidential and may contain trade secrets or be legally privileged. If you have received this email in error you must not use, rely upon, disclose, copy or distribute the contents. Please reply to the sender so that proper delivery can be arranged and delete the email from your computer.
Gemini Data Loggers monitor incoming and outgoing email to ensure satisfactory customer service, maintain company security and prevent abuse of their email system. However, any views expressed in this email are not necessarily those of Gemini and Gemini cannot be held responsible for the content.
Gemini makes best efforts to ensure emails are virus free; however you are advised to carry out your own checks. Gemini does not accept responsibility for any damage resulting from email viruses.
____________________



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click