pyprojection problem

Bram de Greve bram.degreve at
Fri Jan 25 16:35:22 CET 2008

Didrik Pinte wrote:
> Hi guys,
> It seems there is a problem with input arguments using pyprojection.
> When calling Projectionc.new_Projection(*args) with some values as
> unicode and not str, it crashes !
> I guess it's a problem with the swig interface but I really don't know
> how to solve it.
> Any hints ?
> Didrik

By crafting your own, like pyshapelib? =)

/me ducks

Seriously now,

I'm took a _very_ quick glance into projection_wrap.c and
pyprojection.i  and the culprit seems to be lines 65 to 68 in
projection.i.  You recognize the error message on line 68? =)

Two different angles of attack:
(a) modify projection.i to also accept unicode objects, and hope you
find a swig willing to compile projection.i
(b) convert unicode strings to regular strings _in_Python_ before
creating a Projection object.

Remember that you need to encode the unicode string into a narrow
character string at some point.  So you'll have to pick an encoding. 
Either ASCII and throw exceptions when non-ASCII characters are found
(or ANSI or whatever).  Not a big problem as any encoding function will
throw that exception for you.  Or encode as UTF-8 ...


More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)