You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe this commit results in bools written with 1.5.2 to strings in 1.6.1, which causes the value to actually switch if you stored False. This makes upgrading from 1.5.2 to 1.6.1 (and getting the pickle_protocol behavior, thank you for adding that!) difficult. Unfortunately tracking down all the places we might be setting False is also difficult (and tedious). Any ideas about how we can work around this? The only thing I've come up with is forking 1.6 to have the write path set an extra flag for anything with FLAG_TEXT, and then checking for that extra flag on read, monitoring what fraction of our reads come back without that flag, and hoping that eventually it goes to 0.
(pylibmctest) ✔ 12:16 ~ $ python
Python 3.7.3 | packaged by conda-forge | (default, Dec 6 2019, 08:36:57)
[Clang 9.0.0 (tags/RELEASE_900/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylibmc
>>> cl = pylibmc.Client(['localhost:11211'])
>>> cl.set('foo', False)
True
>>> cl.get('foo')
False
>>>
(pylibmctest) ✔ 12:44 ~ $ pip freeze | grep pylibmc
pylibmc==1.5.2
(pylibmctest) ✔ 12:45 ~ $ pip install pylibmc==1.6.1
Collecting pylibmc==1.6.1
Using cached https://files.pythonhosted.org/packages/a7/0c/f7a3af34b05c167a69ed1fc330b06b658dac4ab25b8632c52d1022dd5337/pylibmc-1.6.1.tar.gz
Building wheels for collected packages: pylibmc
Building wheel for pylibmc (setup.py) ... done
Created wheel for pylibmc: filename=pylibmc-1.6.1-cp37-cp37m-macosx_10_9_x86_64.whl size=32878 sha256=5bde92da27513e7024d29f73dd0a9837ebb4c7024d2b553eac62db835d504fdf
Stored in directory: /Users/aaronwebber/Library/Caches/pip/wheels/71/5e/41/6796b369874b1b0345bccf31449e162eadcda85b104922f2de
Successfully built pylibmc
Installing collected packages: pylibmc
Found existing installation: pylibmc 1.5.2
Uninstalling pylibmc-1.5.2:
Successfully uninstalled pylibmc-1.5.2
Successfully installed pylibmc-1.6.1
(pylibmctest) ✔ 12:45 ~ $ python
Python 3.7.3 | packaged by conda-forge | (default, Dec 6 2019, 08:36:57)
[Clang 9.0.0 (tags/RELEASE_900/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylibmc
>>> cl = pylibmc.Client(['localhost:11211'])
>>> cl.get('foo')
'0'
>>> bool(cl.get('foo')) # This is the real problem :(
True
The text was updated successfully, but these errors were encountered:
One possible workaround you can try is to check for the string value '0' when reading the data and convert it back to False. This way, you can handle the previous bool values correctly even with the newer version of pylibmc.
Here's a possible implementation for your case:
importpylibmcdefconvert_to_bool(value):
ifvalue=='0':
returnFalsereturnbool(value)
# Example usagecl=pylibmc.Client(['localhost:11211'])
stored_value=cl.get('foo')
ifstored_valueisnotNone:
foo_value=convert_to_bool(stored_value)
print(foo_value) # This should correctly print False# Now you can use foo_value as a boolean, knowing it has been correctly converted.
By introducing the convert_to_bool function, you can handle the conversion from the string representation back to the correct boolean value. This way, you can maintain compatibility while upgrading to pylibmc 1.6.1.
I believe this commit results in bools written with 1.5.2 to strings in 1.6.1, which causes the value to actually switch if you stored
False
. This makes upgrading from 1.5.2 to 1.6.1 (and getting thepickle_protocol
behavior, thank you for adding that!) difficult. Unfortunately tracking down all the places we might be settingFalse
is also difficult (and tedious). Any ideas about how we can work around this? The only thing I've come up with is forking 1.6 to have the write path set an extra flag for anything withFLAG_TEXT
, and then checking for that extra flag on read, monitoring what fraction of our reads come back without that flag, and hoping that eventually it goes to 0.The text was updated successfully, but these errors were encountered: