This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients georg.brandl, terry.reedy
Date 2008-08-16.20:39:45
SpamBayes Score 6.152864e-08
Marked as misclassified No
Message-id <1218919187.91.0.149398237755.issue3569@psf.upfronthosting.co.za>
In-reply-to
Content
LibRef/built-in functions/eval() has this section

This function can also be used to execute arbitrary code objects (such
as those created by compile()).
In this case pass a code object instead of a string.
The code object must have been compiled passing 'eval' as the kind argument.

As pointed out by Patrick Maupin on py-dev today, the first and third
statements are contradictory: 'arbitrary' != 'limited to kind "eval"'
and the third is wrong in 2.5.  It is still wrong in 3.0b2:

>>> eval(compile('1+2', '', 'eval'))
3
>>> eval(compile('1+2', '', 'exec')) # runs and returns None

Because of the first line, I assume this is intended.

Patrick suggests that the third line be expanded to

In order to return a result other than None to eval's caller,  the code
object must have been compiled passing 'eval' as the kind argument.

I prefer the slightly more compact

In order for eval to return a result other than None, the code object
must have been compiled passing 'eval' as the kind argument.

or even

However eval will return None unless the code object was compiled with
'eval' as the kind argument.
History
Date User Action Args
2008-08-16 20:39:48terry.reedysetrecipients: + terry.reedy, georg.brandl
2008-08-16 20:39:47terry.reedysetmessageid: <1218919187.91.0.149398237755.issue3569@psf.upfronthosting.co.za>
2008-08-16 20:39:47terry.reedylinkissue3569 messages
2008-08-16 20:39:45terry.reedycreate