[Python-Dev] Re: Future division detection
Christopher A. Craig
com-nospam@ccraig.org
05 Nov 2001 12:56:36 -0500
Michael Hudson <mwh@python.net> writes:
> Does this:
>
> int is_future_div(void)
> {
> PyCompilerFlags cf;
> PyEval_MergeCompilerFlags(&cf);
> return cf.cf_flags & CO_FUTURE_DIVISION;
> }
>
> work?
Yes! That's exactly the sort of thing I was looking for. I couldn't
find the "PyEval_MergeCompilerFlags()" call.
> You'll need to change this when future division becomes the default,
> but I think it'll work today. This is a murky dark corner of the
> interpreter, though -- so don't blame me when it breaks!
I knew this, but my alternative was having to change behavior when
future division becomes default, which would be much worse.
When I decided to try to make my module into a patch and bend integers
and longs to my will I knew that I was going to have to enter murky
corners of the interpreter :-)
--
Christopher A. Craig <com-nospam@ccraig.org>