Error: missing terminating character

31 views
Skip to first unread message

Alexander M.

unread,
Nov 10, 2016, 3:32:55 AM11/10/16
to python-cffi
Hi,

I have a function with escape characters and ". Now when I try to build my module in the API out of line way, it says there is an terminating character missing. 
e.g.:

fprintf( sterr, " foo ", arga, argb, argc );

is going to be parsed (as seen in the module.c):

fprintf( stderr, " foo
",
              arga, argb, argc );

where the ", is clearly out of scope, an the rest of the function ins just not being recognised.

What am I missing?

Alexander M.

unread,
Nov 10, 2016, 3:38:22 AM11/10/16
to python-cffi
Sorry, need to correct myself:

fprintf( sterr, " foo\n\n", arga, argb, argc );

so, I think the problem is the escaping \n. how can I realise this in the set_source function?

Armin Rigo

unread,
Nov 10, 2016, 3:40:50 AM11/10/16
to pytho...@googlegroups.com
Hi Alexander,

On 10 November 2016 at 09:38, Alexander M. <skug...@gmail.com> wrote:
> Sorry, need to correct myself:
>
> fprintf( sterr, " foo\n\n", arga, argb, argc );

The '\n' is interpreted by Python as meaning "the end-of-line char".
To avoid that, use a r""" ... """:

ffibuilder.set_source("_foo", r"""

fprintf( sterr, " foo\n\n", arga, argb, argc );

""")


A bientôt,

Armin.

Alexander M.

unread,
Nov 10, 2016, 3:46:22 AM11/10/16
to python-cffi
Thanks a million!
Reply all
Reply to author
Forward
0 new messages