[PATCH] util.h: Defined macros for working with strings using the python C API

Antoine Pitrou solipsis at pitrou.net
Fri Jun 18 01:46:55 CDT 2010


Renato Cunha <renatoc <at> gmail.com> writes:
> 
> +//#define PyString_Size PyUnicode_GET_SIZE

C++-style comments will break some C compilers. I'm not sure what Mercurial's
policy is with that but I just wanted to point it out.

> +#define PyString_AsString(string)
PyBytes_AsString(PyUnicode_AsLatin1String(string))

That doesn't strike me as a particularly recommendable thing to do, unless you
are sure that latin-1 is ok for every unicode -> `char *` conversion inside the
C extensions.
(that's why I suggested that you use the abstract "%" operator instead in the
repr() implementation)

Regards

Antoine.




More information about the Mercurial-devel mailing list