mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Patch #1550800: make exec a function.
This commit is contained in:
parent
4e472e05bd
commit
7cae87ca7b
105 changed files with 1246 additions and 1583 deletions
|
@ -44,22 +44,22 @@ hName = sys.argv[1]
|
|||
# setup our creatorFunc to test the requested hash
|
||||
#
|
||||
if hName in ('_md5', '_sha'):
|
||||
exec 'import '+hName
|
||||
exec 'creatorFunc = '+hName+'.new'
|
||||
exec('import '+hName)
|
||||
exec('creatorFunc = '+hName+'.new')
|
||||
print "testing speed of old", hName, "legacy interface"
|
||||
elif hName == '_hashlib' and len(sys.argv) > 3:
|
||||
import _hashlib
|
||||
exec 'creatorFunc = _hashlib.%s' % sys.argv[2]
|
||||
exec('creatorFunc = _hashlib.%s' % sys.argv[2])
|
||||
print "testing speed of _hashlib.%s" % sys.argv[2], getattr(_hashlib, sys.argv[2])
|
||||
elif hName == '_hashlib' and len(sys.argv) == 3:
|
||||
import _hashlib
|
||||
exec 'creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2]
|
||||
exec('creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2])
|
||||
print "testing speed of _hashlib.new(%r)" % sys.argv[2]
|
||||
elif hasattr(hashlib, hName) and callable(getattr(hashlib, hName)):
|
||||
creatorFunc = getattr(hashlib, hName)
|
||||
print "testing speed of hashlib."+hName, getattr(hashlib, hName)
|
||||
else:
|
||||
exec "creatorFunc = lambda x=hashlib.new : x(%r)" % hName
|
||||
exec("creatorFunc = lambda x=hashlib.new : x(%r)" % hName)
|
||||
print "testing speed of hashlib.new(%r)" % hName
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue