Python builtin hashfunc closure fix
If the wrong return type in the hash function was used, an error: SystemError: error return without exception set was raised Add some tests for testing builtin slots
This commit is contained in:
parent
2740812970
commit
f778ee19df
4 changed files with 105 additions and 2 deletions
26
Examples/test-suite/python/python_builtin_runme.py
Normal file
26
Examples/test-suite/python/python_builtin_runme.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from python_builtin import *
|
||||
|
||||
if is_python_builtin():
|
||||
# Test 1 for tp_hash
|
||||
if hash(SimpleValue(222)) != 222:
|
||||
raise RuntimeError("tp_hash not working")
|
||||
|
||||
# Test 2 for tp_hash
|
||||
try:
|
||||
# Was incorrectly raising: SystemError: error return without exception set
|
||||
h = hash(BadHashFunctionReturnType())
|
||||
raise RuntimeError("Missing TypeError")
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# Test 3 for tp_hash
|
||||
passed = False
|
||||
try:
|
||||
h = hash(ExceptionHashFunction())
|
||||
except RuntimeError, e:
|
||||
passed = str(e).find("oops") != -1
|
||||
pass
|
||||
|
||||
if not passed:
|
||||
raise RuntimeError("did not catch exception in hash()")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue