Created
December 20, 2011 20:52
-
-
Save bukzor/1503218 to your computer and use it in GitHub Desktop.
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
# reproduce bug: https://gist.github.com/1503176 | |
from pylibmc.test import make_test_client | |
class Foo(object): | |
def __getstate__(self): | |
return dict(a=1) | |
def __setstate__(self, d): | |
assert d['a'] == 1 | |
def break_pickling(): | |
global Foo | |
class BrokenFoo(object): | |
def __init__(self): | |
raise AssertionError("this function is *never* called") | |
def __setstate__(self, d): | |
raise NotImplementedError('BrokenFoo.__setstate__') | |
Foo = BrokenFoo | |
def poke_memcache(): | |
c = make_test_client() | |
c.set("test_key", Foo()) | |
result = c.get_multi(['test_key']) | |
print 'RESULT(1):', result | |
break_pickling() | |
result = c.get_multi(['test_key']) | |
print 'RESULT(2):', result | |
def allocate_dicts(): | |
x = {} | |
print 'x', x | |
y = {} | |
print 'y', y | |
z = {} | |
print 'z', z | |
# Entry point: | |
poke_memcache() | |
allocate_dicts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment