[GRASS-dev] grass7 on mac OSX

Glynn Clements glynn at gclements.plus.com
Fri Jun 4 14:04:27 EDT 2010


Barton Michael wrote:

> Once you or others think there is a potential fix for GRASS for OSX,
> I'm happy to give it a try.

Can you try the latest version? It will still fail, but it should
provide more information (specifically, the "invalid \x escape"
exception should now report the string that it's trying to decode).

ctypesgen ignores errors from the preprocessor, but errors within
ctypesgen itself (e.g. the decoding error) tend to be fatal.

FWIW, the code acknowledges that the decoding may not be quite right
(it decodes string literals according to Python's syntax, which is
modelled on C but may have subtle differences):

        # Unescaping probably not perfect but close enough.
        value = value[1:-1].decode('string_escape')

The Python language reference says of \x escapes:

	Unlike in Standard C, exactly two hex digits are required

Assuming that's the issue, it should suffice to replace the above
with:

	try:
	    value = value[1:-1].decode('string_escape')
	except ValueError, e:
	    value = re.sub(r'\\x([0-9a-fA-F])(?![0-9a-fA-F])',
	                   r'\x0\1',
	                   value[1:-1]).decode('string_escape')

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list