Skip to content

Commit 0b47212

Browse files
niconoetimgraham
authored andcommitted
Fix touch(..., time=0) sending invalid command to memcache
Without the trailing '0', the command is invalid.
1 parent 4670752 commit 0b47212

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* Fixed storing non-ASCII values on Python 2 and binary values on Python 3
1717
(PR from Nicolas Noé) #135
1818

19+
* Fixed touch(..., time=0) command (PR from Nicolas Noé) #137
20+
1921
Fri, 27 May 2016 13:44:55 -0600 Sean Reifschneider <[email protected]>
2022

2123
* 1.58 release.

memcache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def _deletetouch(self, expected, cmd, key, time=0, noreply=False):
553553
if not server:
554554
return 0
555555
self._statlog(cmd)
556-
if time is not None and time != 0:
556+
if time is not None:
557557
headers = str(time)
558558
else:
559559
headers = None

tests/test_memcache.py

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ def test_delete(self):
5151
self.assertEqual(result, True)
5252
self.assertEqual(self.mc.get("long"), None)
5353

54+
@mock.patch.object(_Host, 'send_cmd')
55+
@mock.patch.object(_Host, 'readline')
56+
def test_touch(self, mock_readline, mock_send_cmd):
57+
with captured_stderr():
58+
self.mc.touch('key')
59+
mock_send_cmd.assert_called_with(b'touch key 0')
60+
5461
def test_get_multi(self):
5562
self.check_setget("gm_a_string", "some random string")
5663
self.check_setget("gm_an_integer", 42)

0 commit comments

Comments
 (0)