Luke Mewburn schrieb: > On Mon, Sep 10, 2007 at 07:37:02AM +0200, "Martin v. L?wis" wrote: > | In principle, it is possible to deal with these in ParseTuple. > | To do so: > | a) in configure.in, make a configure-time check to compute the > | size of the type, and possibly its signedness. > | b) in _cursesmodule.c, make a conditional define of ATTR_T_FMT, > | which would be either "i" or "l" (or #error if it's neither > | the size of int nor the size of long). Then rely on string > | concatenation in using that define. > > Are there some good examples in the Python source where > this technique has been used already?
Not directly. A check for the size of a library type can be found for fpos_t, but there, no ParseTuple depends on it. An example for using variable formatters (though again not for ParseTuple) is PY_FORMAT_SIZE_T. > Or were you proposing a cleaner solution that could be > experimented with? More that, yes. > | I have a GCC patch which checks for correctness of ParseTuple > | calls (in terms of data size) if you are interested. > > Sounds like a useful variation of the standard -Wformat stuff. Indeed, it's an extension to it. Unfortunately, introducing new kinds of formats is only possible by editing GCC (and then, the existing framework is focussed on %-style patterns, so I had to bypass that framework as well - but there were hooks for doing so). Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com