-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[Disclaimer: not an official response, just some bystander who happens to have
delved deep into the code of pyPgSQL, while resisting the urge to fork
it. ;-) ]
> I've experimented with hacking PgSQL.py to use isinstance() in the
> various places instead. ie. Instead of:
>
> if type(obj) is UnicodeType:
> do_something()
This way of checking types is deprecated, exactly because of the problem you
encountered.
> I've changed it to:
>
> if isinstance(obj, UnicodeType):
> do_something()
This is how it's supposed to be done, at this moment.
> In my case at least, this appears to fix things, but I haven't tested it
> intensively.
>
> I realise that sub-classing 'str' and 'unicode' isn't a normal thing for
> most people to do.
You are definitely supposed to be able to do that.
> Is that the only reason that the 'is' operator was used, or is it more
> complicated than that?
Just historical reasons, probably.
> If someone who better understands the inner workings of pyPgSQL could
> clarify it for me, I'd appreciate it. Otherwise I'll go ahead and
> report it as a bug.
I'm not claiming to be an expert, but I didn't see anything in the code that
needs the original unicode type, and nothing else. So yes, you should go
ahead, IMO.
- --
Nicola Larosa - ni...@te...
Unchecked police and military power undermine personal security,
and increase the risk of terrorism attacks. Unchecked terrorism only
increases the risk of terrorism attacks. Statistically, if both are
possible, I am more at risk from the first, and am likely to lose more.
-- Daniel Staal, August 2004
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFBfz/VXv0hgDImBm4RAhi5AKCAYlHCdAdirtQJRcjhGRlTYxtfFACgg5Ay
748fHMKPiUtq50djdy7gtbI=
=4piy
-----END PGP SIGNATURE-----
|