Last active
August 29, 2015 14:06
-
-
Save julianhille/4ef166e9d375ecd46ff9 to your computer and use it in GitHub Desktop.
found a segfault in python3 / py.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#needs py.test and needs unittest | |
# python -m py.test segfault.py | |
# works with unittest only | |
# used: Python 3.4.1.1 (default, Aug 24 2014, 21:32:40) | |
import unittest | |
class TestCase(unittest.TestCase): | |
def test_bug(self): | |
with self.assertRaises(TypeError) as context: | |
segfault(**{}) | |
def wrapper1(): | |
def wrap(function): | |
def wrap_deeper(*args, **kwargs): | |
return function(**kwargs) | |
return wrap_deeper | |
return wrap | |
@wrapper1() | |
def segfault(**body): | |
test = {} | |
try: | |
raise TypeError({test}) # raises an unhashable error | |
except NoneExistent: | |
raise TypeError() | |
return {} | |
if __name__ == '__main__': | |
unittest.main() | |
# except NoneExistent makes a difference!!!! | |
# ** in def segfault(**body): body makes a difference | |
# ** in return function(**kwargs) makes a different | |
# with self.assertRaises(TypeError) as context: | |
# segfault(**{}) | |
# removing here the with and only call the segfault function. this makes a difference |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment