[Zope3-dev] Re: Psycopgda adapter, should _conv_str do NULL check?

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Oct 16 08:32:53 EDT 2004


On Wednesday 13 October 2004 08:20, Derrick Hudson wrote:
> | def _conv_string(str):
> |     return str.decode(PG_ENCODING)
> |
> | However, if I have a NULL field in the database, then str.decode fails
> | with AttributeError: 'NoneType' object has no attribute 'decode'
>
> Good catch.

<snip>

> I would suggest something like
>
>     def _conv_string(s):
>         if s is not None :
>             s = s.decode(PG_ENCODING)
>         return s

Yep. I have committed this fix to the repository.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-dev mailing list