[Python-modules-commits] r32412 - in packages/python-memcache/trunk/debian (9 files)
zigo at users.alioth.debian.org
zigo at users.alioth.debian.org
Thu Apr 23 22:43:47 UTC 2015
Date: Thursday, April 23, 2015 @ 22:43:46
Author: zigo
Revision: 32412
* Added patch from Victor Stinner to port the package to Python 3.
* Now runs unit tests when building the package:
- Build-Depends: memcached, nose, six.
- Added nose as build-depends, and run unit tests.
- Added debian/setup-test-env-memcached.sh to start memcached on
non-standard port (which is compatible with building with sbuild).
* Standards-Version: 3.9.6.
* Added dh-python as build-depends.
Added:
packages/python-memcache/trunk/debian/patches/
packages/python-memcache/trunk/debian/patches/port-memcache-to-python3.patch
packages/python-memcache/trunk/debian/patches/series
packages/python-memcache/trunk/debian/patches/using-port-11212-instead-of-standard-11211.patch
packages/python-memcache/trunk/debian/setup-test-env-memcached.sh
Modified:
packages/python-memcache/trunk/debian/changelog
packages/python-memcache/trunk/debian/control
packages/python-memcache/trunk/debian/copyright
packages/python-memcache/trunk/debian/rules
Modified: packages/python-memcache/trunk/debian/changelog
===================================================================
--- packages/python-memcache/trunk/debian/changelog 2015-04-23 22:24:27 UTC (rev 32411)
+++ packages/python-memcache/trunk/debian/changelog 2015-04-23 22:43:46 UTC (rev 32412)
@@ -1,3 +1,16 @@
+python-memcache (1.54+20150423+git+48e882719c-1) experimental; urgency=medium
+
+ * Added patch from Victor Stinner to port the package to Python 3.
+ * Now runs unit tests when building the package:
+ - Build-Depends: memcached, nose, six.
+ - Added nose as build-depends, and run unit tests.
+ - Added debian/setup-test-env-memcached.sh to start memcached on
+ non-standard port (which is compatible with building with sbuild).
+ * Standards-Version: 3.9.6.
+ * Added dh-python as build-depends.
+
+ -- Thomas Goirand <zigo at debian.org> Thu, 23 Apr 2015 21:47:37 +0000
+
python-memcache (1.53+2014.06.08.git.918e88c496-1) unstable; urgency=medium
* New upstream release.
Modified: packages/python-memcache/trunk/debian/control
===================================================================
--- packages/python-memcache/trunk/debian/control 2015-04-23 22:24:27 UTC (rev 32411)
+++ packages/python-memcache/trunk/debian/control 2015-04-23 22:43:46 UTC (rev 32412)
@@ -2,22 +2,31 @@
Section: python
Priority: optional
Maintainer: Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
-Uploaders: Carl Chenet <chaica at ohmytux.com>, Thomas Goirand <zigo at debian.org>
+Uploaders: Carl Chenet <chaica at ohmytux.com>,
+ Thomas Goirand <zigo at debian.org>,
Build-Depends: debhelper (>= 9),
+ dh-python,
python-all (>= 2.6.6-3),
python-setuptools,
python3-all,
- python3-setuptools
-Standards-Version: 3.9.5
+ python3-setuptools,
+Build-Depends-Indep: memcached,
+ python-nose,
+ python-six,
+ python3-nose,
+ python3-six,
+Standards-Version: 3.9.6
Homepage: http://www.tummy.com/Community/software/python-memcached/
Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/python-memcache/trunk/
Vcs-Browser: http://anonscm.debian.org/viewvc/python-modules/packages/python-memcache/trunk/
Package: python-memcache
Architecture: all
-Depends: python-six, ${misc:Depends}, ${python:Depends}
-Suggests: memcached
-Description: pure python memcached client
+Depends: python-six,
+ ${misc:Depends},
+ ${python:Depends},
+Suggests: memcached,
+Description: pure Python memcached client
This software is a 100% Python interface to the memcached memory cache
daemon. It is the client side software which allows storing values in
one or more, possibly remote, memcached servers.
@@ -26,9 +35,11 @@
Package: python3-memcache
Architecture: all
-Depends: python3-six, ${misc:Depends}, ${python3:Depends}
-Suggests: memcached
-Description: pure python memcached client - Python 3.x
+Depends: python3-six,
+ ${misc:Depends},
+ ${python3:Depends},
+Suggests: memcached,
+Description: pure Python memcached client - Python 3.x
This software is a 100% Python interface to the memcached memory cache daemon.
It is the client side software which allows storing values in one or more,
possibly remote, memcached servers.
Modified: packages/python-memcache/trunk/debian/copyright
===================================================================
--- packages/python-memcache/trunk/debian/copyright 2015-04-23 22:24:27 UTC (rev 32411)
+++ packages/python-memcache/trunk/debian/copyright 2015-04-23 22:43:46 UTC (rev 32412)
@@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: python-memcached
-Upstream-Contact: Sean Reifschneider <jafo at tummy.com>
+Upstream-Contact: Sean Reifschneider <jafo at tummy.com>
Source: git://github.com/linsomniac/python-memcached.git
Files: debian/*
Added: packages/python-memcache/trunk/debian/patches/port-memcache-to-python3.patch
===================================================================
--- packages/python-memcache/trunk/debian/patches/port-memcache-to-python3.patch (rev 0)
+++ packages/python-memcache/trunk/debian/patches/port-memcache-to-python3.patch 2015-04-23 22:43:46 UTC (rev 32412)
@@ -0,0 +1,609 @@
+Description: Port memcache to Python 3
+ * travis: make python 3 tests voting (cannot fail anymore)
+ * setup.py: add Python 3 classifiers
+ * Encode unicode key to UTF-8: add _encode_key() method
+ * Add _encode_cmd() helper method to format a memcache command as a byte
+ string (bytes%args will only be supported in Python 3.5)
+ * Rewrite _map_and_prefix_keys() code converting keys
+ * _val_to_store_info() now accepts Unicode: Unicode is encoded to UTF-8
+ * _set('cas') doesn't call _val_to_store_info() anymore when it's not
+ needed: begin by checking if the key is in the cas_ids dictionary
+ * Process server reply as bytes
+ * _recv_value() now clears the _FLAG_COMPRESSED flag after decompressing
+ to simplify the code
+ * On Python 3, _recv_value() now decodes byte strings from UTF-8
+ * Simplify check_key(), _encode_key() now encodes Unicode to UTF-8
+ * Replace u'...' with six.u('...') in tests for Python 3.2
+Author: Victor Stinner <vstinner at redhat.com>
+Date: Thu, 23 Apr 2015 15:29:57 +0200
+Origin: upstream, https://github.com/haypo/python-memcached/commit/04f1c78c13bd54050b1d2d3baa9e86d9e79b3629.patch
+Last-Update: 2015-04-23
+
+diff --git a/.travis.yml b/.travis.yml
+index fe3c745..0899d80 100644
+--- a/.travis.yml
++++ b/.travis.yml
+@@ -6,11 +6,6 @@ python:
+ - 3.3
+ - 3.4
+ - pypy
+-matrix:
+- allow_failures:
+- - python: 3.2
+- - python: 3.3
+- - python: 3.4
+ services:
+ - memcached
+ install: python setup.py install
+diff --git a/memcache.py b/memcache.py
+index 80770ed..0612d4b 100644
+--- a/memcache.py
++++ b/memcache.py
+@@ -62,7 +62,7 @@
+
+ def cmemcache_hash(key):
+ return (
+- (((binascii.crc32(key.encode('ascii')) & 0xffffffff)
++ (((binascii.crc32(key) & 0xffffffff)
+ >> 16) & 0x7fff) or 1)
+ serverHashFunction = cmemcache_hash
+
+@@ -73,19 +73,19 @@ def useOldServerHashFunction():
+ serverHashFunction = binascii.crc32
+
+ from io import BytesIO
+-try:
+- unicode
+-except NameError:
+- _has_unicode = False
++if six.PY2:
++ try:
++ unicode
++ except NameError:
++ _has_unicode = False
++ else:
++ _has_unicode = True
+ else:
+ _has_unicode = True
+
+-try:
+- _str_cls = basestring
+-except NameError:
+- _str_cls = str
++_str_cls = six.string_types
+
+-valid_key_chars_re = re.compile('[\x21-\x7e\x80-\xff]+$')
++valid_key_chars_re = re.compile(b'[\x21-\x7e\x80-\xff]+$')
+
+
+ # Original author: Evan Martin of Danga Interactive
+@@ -249,6 +249,32 @@ def __init__(self, servers, debug=0, pickleProtocol=0,
+ except TypeError:
+ self.picklerIsKeyword = False
+
++ def _encode_key(self, key):
++ if isinstance(key, tuple):
++ if isinstance(key[1], six.text_type):
++ return (key[0], key[1].encode('utf8'))
++ elif isinstance(key, six.text_type):
++ return key.encode('utf8')
++ return key
++
++ def _encode_cmd(self, cmd, key, headers, noreply, *args):
++ cmd_bytes = cmd.encode() if six.PY3 else cmd
++ fullcmd = [cmd_bytes, b' ', key]
++
++ if headers:
++ if six.PY3:
++ headers = headers.encode()
++ fullcmd.append(b' ')
++ fullcmd.append(headers)
++
++ if noreply:
++ fullcmd.append(b' noreply')
++
++ if args:
++ fullcmd.append(b' ')
++ fullcmd.extend(args)
++ return b''.join(fullcmd)
++
+ def reset_cas(self):
+ """Reset the cas cache.
+
+@@ -475,7 +501,7 @@ def delete(self, key, time=0, noreply=False):
+ reply.
+ @rtype: int
+ '''
+- return self._deletetouch(['DELETED', 'NOT_FOUND'], "delete", key,
++ return self._deletetouch([b'DELETED', b'NOT_FOUND'], "delete", key,
+ time, noreply)
+
+ def touch(self, key, time=0, noreply=False):
+@@ -491,23 +517,23 @@ def touch(self, key, time=0, noreply=False):
+ reply.
+ @rtype: int
+ '''
+- return self._deletetouch(['TOUCHED'], "touch", key, time, noreply)
++ return self._deletetouch([b'TOUCHED'], "touch", key, time, noreply)
+
+ def _deletetouch(self, expected, cmd, key, time=0, noreply=False):
++ key = self._encode_key(key)
+ if self.do_check_key:
+ self.check_key(key)
+ server, key = self._get_server(key)
+ if not server:
+ return 0
+ self._statlog(cmd)
+- extra = ' noreply' if noreply else ''
+ if time is not None and time != 0:
+- cmd = "%s %s %d%s" % (cmd, key, time, extra)
++ fullcmd = self._encode_cmd(cmd, key, str(time), noreply)
+ else:
+- cmd = "%s %s%s" % (cmd, key, extra)
++ fullcmd = self._encode_cmd(cmd, key, None, noreply)
+
+ try:
+- server.send_cmd(cmd)
++ server.send_cmd(fullcmd)
+ if noreply:
+ return 1
+ line = server.readline()
+@@ -573,20 +599,20 @@ def decr(self, key, delta=1, noreply=False):
+ return self._incrdecr("decr", key, delta, noreply)
+
+ def _incrdecr(self, cmd, key, delta, noreply=False):
++ key = self._encode_key(key)
+ if self.do_check_key:
+ self.check_key(key)
+ server, key = self._get_server(key)
+ if not server:
+ return None
+ self._statlog(cmd)
+- extra = ' noreply' if noreply else ''
+- cmd = "%s %s %d%s" % (cmd, key, delta, extra)
++ fullcmd = self._encode_cmd(cmd, key, str(delta), noreply)
+ try:
+- server.send_cmd(cmd)
++ server.send_cmd(fullcmd)
+ if noreply:
+ return
+ line = server.readline()
+- if line is None or line.strip() == 'NOT_FOUND':
++ if line is None or line.strip() == b'NOT_FOUND':
+ return None
+ return int(line)
+ except socket.error as msg:
+@@ -715,6 +741,7 @@ def _map_and_prefix_keys(self, key_iterable, key_prefix):
+ stuff onto that server, as well as the mapping of prefixed key
+ -> original key.
+ """
++ key_prefix = self._encode_key(key_prefix)
+ # Check it just once ...
+ key_extra_len = len(key_prefix)
+ if key_prefix and self.do_check_key:
+@@ -730,17 +757,31 @@ def _map_and_prefix_keys(self, key_iterable, key_prefix):
+ # Tuple of hashvalue, key ala _get_server(). Caller is
+ # essentially telling us what server to stuff this on.
+ # Ensure call to _get_server gets a Tuple as well.
+- str_orig_key = str(orig_key[1])
++ serverhash, key = orig_key
++
++ key = self._encode_key(key)
++ if not isinstance(key, six.binary_type):
++ # set_multi supports int / long keys.
++ key = str(key)
++ if six.PY3:
++ key = key.encode('utf8')
++ bytes_orig_key = key
+
+ # Gotta pre-mangle key before hashing to a
+ # server. Returns the mangled key.
+ server, key = self._get_server(
+- (orig_key[0], key_prefix + str_orig_key))
++ (serverhash, key_prefix + key))
++
+ orig_key = orig_key[1]
+ else:
+- # set_multi supports int / long keys.
+- str_orig_key = str(orig_key)
+- server, key = self._get_server(key_prefix + str_orig_key)
++ key = self._encode_key(orig_key)
++ if not isinstance(key, six.binary_type):
++ # set_multi supports int / long keys.
++ key = str(key)
++ if six.PY3:
++ key = key.encode('utf8')
++ bytes_orig_key = key
++ server, key = self._get_server(key_prefix + key)
+
+ # alert when passed in key is None
+ if orig_key is None:
+@@ -748,7 +789,7 @@ def _map_and_prefix_keys(self, key_iterable, key_prefix):
+
+ # Now check to make sure key length is proper ...
+ if self.do_check_key:
+- self.check_key(str_orig_key, key_extra_len=key_extra_len)
++ self.check_key(bytes_orig_key, key_extra_len=key_extra_len)
+
+ if not server:
+ continue
+@@ -830,7 +871,6 @@ def set_multi(self, mapping, time=0, key_prefix='', min_compress_len=0,
+ dead_servers = []
+ notstored = [] # original keys.
+
+- extra = ' noreply' if noreply else ''
+ for server in six.iterkeys(server_keys):
+ bigcmd = []
+ write = bigcmd.append
+@@ -840,16 +880,15 @@ def set_multi(self, mapping, time=0, key_prefix='', min_compress_len=0,
+ mapping[prefixed_to_orig_key[key]],
+ min_compress_len)
+ if store_info:
+- msg = "set %s %d %d %d%s\r\n%s\r\n"
+- write(msg % (key,
+- store_info[0],
+- time,
+- store_info[1],
+- extra,
+- store_info[2]))
++ flags, len_val, val = store_info
++ headers = "%d %d %d" % (flags, time, len_val)
++ fullcmd = self._encode_cmd('set', key, headers,
++ noreply,
++ b'\r\n', val, b'\r\n')
++ write(fullcmd)
+ else:
+ notstored.append(prefixed_to_orig_key[key])
+- server.send_cmds(''.join(bigcmd))
++ server.send_cmds(b''.join(bigcmd))
+ except socket.error as msg:
+ if isinstance(msg, tuple):
+ msg = msg[1]
+@@ -889,16 +928,22 @@ def _val_to_store_info(self, val, min_compress_len):
+ the new value itself.
+ """
+ flags = 0
+- if isinstance(val, str):
++ if isinstance(val, six.binary_type):
+ pass
++ elif isinstance(val, six.text_type):
++ val = val.encode('utf-8')
+ elif isinstance(val, int):
+ flags |= Client._FLAG_INTEGER
+- val = "%d" % val
++ val = str(val)
++ if six.PY3:
++ val = val.encode('ascii')
+ # force no attempt to compress this silly string.
+ min_compress_len = 0
+- elif isinstance(val, long):
++ elif six.PY2 and isinstance(val, long):
+ flags |= Client._FLAG_LONG
+- val = "%d" % val
++ val = str(val)
++ if six.PY3:
++ val = val.encode('ascii')
+ # force no attempt to compress this silly string.
+ min_compress_len = 0
+ else:
+@@ -932,6 +977,7 @@ def _val_to_store_info(self, val, min_compress_len):
+ return (flags, len(val), val)
+
+ def _set(self, cmd, key, val, time, min_compress_len=0, noreply=False):
++ key = self._encode_key(key)
+ if self.do_check_key:
+ self.check_key(key)
+ server, key = self._get_server(key)
+@@ -941,30 +987,29 @@ def _set(self, cmd, key, val, time, min_compress_len=0, noreply=False):
+ def _unsafe_set():
+ self._statlog(cmd)
+
++ if cmd == 'cas' and key not in self.cas_ids:
++ return self._set('set', key, val, time, min_compress_len,
++ noreply)
++
+ store_info = self._val_to_store_info(val, min_compress_len)
+ if not store_info:
+ return(0)
++ flags, len_val, encoded_val = store_info
+
+- extra = ' noreply' if noreply else ''
+ if cmd == 'cas':
+- if key not in self.cas_ids:
+- return self._set('set', key, val, time, min_compress_len,
+- noreply)
+- fullcmd = "%s %s %d %d %d %d%s\r\n%s" % (
+- cmd, key, store_info[0], time, store_info[1],
+- self.cas_ids[key], extra, store_info[2])
++ headers = ("%d %d %d %d"
++ % (flags, time, len_val, self.cas_ids[key]))
+ else:
+- fullcmd = "%s %s %d %d %d%s\r\n%s" % (
+- cmd, key, store_info[0],
+- time, store_info[1], extra, store_info[2]
+- )
++ headers = "%d %d %d" % (flags, time, len_val)
++ fullcmd = self._encode_cmd(cmd, key, headers, noreply,
++ b'\r\n', encoded_val)
+
+ try:
+ server.send_cmd(fullcmd)
+ if noreply:
+ return True
+- return(server.expect("STORED", raise_exception=True)
+- == "STORED")
++ return(server.expect(b"STORED", raise_exception=True)
++ == b"STORED")
+ except socket.error as msg:
+ if isinstance(msg, tuple):
+ msg = msg[1]
+@@ -983,6 +1028,7 @@ def _unsafe_set():
+ return 0
+
+ def _get(self, cmd, key):
++ key = self._encode_key(key)
+ if self.do_check_key:
+ self.check_key(key)
+ server, key = self._get_server(key)
+@@ -993,7 +1039,9 @@ def _unsafe_get():
+ self._statlog(cmd)
+
+ try:
+- server.send_cmd("%s %s" % (cmd, key))
++ cmd_bytes = cmd.encode() if six.PY3 else cmd
++ fullcmd = b''.join((cmd_bytes, b' ', key))
++ server.send_cmd(fullcmd)
+ rkey = flags = rlen = cas_id = None
+
+ if cmd == 'gets':
+@@ -1012,7 +1060,7 @@ def _unsafe_get():
+ try:
+ value = self._recv_value(server, flags, rlen)
+ finally:
+- server.expect("END", raise_exception=True)
++ server.expect(b"END", raise_exception=True)
+ except (_Error, socket.error) as msg:
+ if isinstance(msg, tuple):
+ msg = msg[1]
+@@ -1111,7 +1159,8 @@ def get_multi(self, keys, key_prefix=''):
+ dead_servers = []
+ for server in six.iterkeys(server_keys):
+ try:
+- server.send_cmd("get %s" % " ".join(server_keys[server]))
++ fullcmd = b"get " + b" ".join(server_keys[server])
++ server.send_cmd(fullcmd)
+ except socket.error as msg:
+ if isinstance(msg, tuple):
+ msg = msg[1]
+@@ -1126,7 +1175,7 @@ def get_multi(self, keys, key_prefix=''):
+ for server in six.iterkeys(server_keys):
+ try:
+ line = server.readline()
+- while line and line != 'END':
++ while line and line != b'END':
+ rkey, flags, rlen = self._expectvalue(server, line)
+ # Bo Yang reports that this can sometimes be None
+ if rkey is not None:
+@@ -1144,7 +1193,7 @@ def _expect_cas_value(self, server, line=None, raise_exception=False):
+ if not line:
+ line = server.readline(raise_exception)
+
+- if line and line[:5] == 'VALUE':
++ if line and line[:5] == b'VALUE':
+ resp, rkey, flags, len, cas_id = line.split()
+ return (rkey, int(flags), int(len), int(cas_id))
+ else:
+@@ -1154,7 +1203,7 @@ def _expectvalue(self, server, line=None, raise_exception=False):
+ if not line:
+ line = server.readline(raise_exception)
+
+- if line and line[:5] == 'VALUE':
++ if line and line[:5] == b'VALUE':
+ resp, rkey, flags, len = line.split()
+ flags = int(flags)
+ rlen = int(len)
+@@ -1174,14 +1223,21 @@ def _recv_value(self, server, flags, rlen):
+
+ if flags & Client._FLAG_COMPRESSED:
+ buf = self.decompressor(buf)
++ flags &= ~Client._FLAG_COMPRESSED
+
+- if flags == 0 or flags == Client._FLAG_COMPRESSED:
+- # Either a bare string or a compressed string now decompressed...
+- val = buf
++ if flags == 0:
++ # Bare string
++ if six.PY3:
++ val = buf.decode('utf8')
++ else:
++ val = buf
+ elif flags & Client._FLAG_INTEGER:
+ val = int(buf)
+ elif flags & Client._FLAG_LONG:
+- val = long(buf)
++ if six.PY3:
++ val = int(buf)
++ else:
++ val = long(buf)
+ elif flags & Client._FLAG_PICKLE:
+ try:
+ file = BytesIO(buf)
+@@ -1221,24 +1277,17 @@ def check_key(self, key, key_extra_len=0):
+ # key is empty but there is some other component to key
+ return
+
+- # Make sure we're not a specific unicode type, if we're old enough that
+- # it's a separate type.
+- if _has_unicode is True and isinstance(key, unicode):
+- raise Client.MemcachedStringEncodingError(
+- "Keys must be str()'s, not unicode. Convert your unicode "
+- "strings using mystring.encode(charset)!")
+- if not isinstance(key, str):
+- raise Client.MemcachedKeyTypeError("Key must be str()'s")
+-
+- if isinstance(key, _str_cls):
+- if (self.server_max_key_length != 0 and
+- len(key) + key_extra_len > self.server_max_key_length):
+- raise Client.MemcachedKeyLengthError(
+- "Key length is > %s" % self.server_max_key_length
+- )
+- if not valid_key_chars_re.match(key):
+- raise Client.MemcachedKeyCharacterError(
+- "Control/space characters not allowed (key=%r)" % key)
++ if not isinstance(key, six.binary_type):
++ raise Client.MemcachedKeyTypeError("Key must be a binary string")
++
++ if (self.server_max_key_length != 0 and
++ len(key) + key_extra_len > self.server_max_key_length):
++ raise Client.MemcachedKeyLengthError(
++ "Key length is > %s" % self.server_max_key_length
++ )
++ if not valid_key_chars_re.match(key):
++ raise Client.MemcachedKeyCharacterError(
++ "Control/space characters not allowed (key=%r)" % key)
+
+
+ class _Host(object):
+@@ -1286,7 +1335,7 @@ def __init__(self, host, debug=0, dead_retry=_DEAD_RETRY,
+ self.socket = None
+ self.flush_on_next_connect = 0
+
+- self.buffer = ''
++ self.buffer = b''
+
+ def debuglog(self, str):
+ if self.debug:
+@@ -1329,7 +1378,7 @@ def _get_socket(self):
+ self.mark_dead("connect: %s" % msg)
+ return None
+ self.socket = s
+- self.buffer = ''
++ self.buffer = b''
+ if self.flush_on_next_connect:
+ self.flush()
+ self.flush_on_next_connect = 0
+@@ -1341,10 +1390,14 @@ def close_socket(self):
+ self.socket = None
+
+ def send_cmd(self, cmd):
+- self.socket.sendall(cmd + '\r\n')
++ if isinstance(cmd, six.text_type):
++ cmd = cmd.encode('utf8')
++ self.socket.sendall(cmd + b'\r\n')
+
+ def send_cmds(self, cmds):
+ """cmds already has trailing \r\n's applied."""
++ if isinstance(cmds, six.text_type):
++ cmds = cmds.encode('utf8')
+ self.socket.sendall(cmds)
+
+ def readline(self, raise_exception=False):
+@@ -1357,10 +1410,10 @@ def readline(self, raise_exception=False):
+ if self.socket:
+ recv = self.socket.recv
+ else:
+- recv = lambda bufsize: ''
++ recv = lambda bufsize: b''
+
+ while True:
+- index = buf.find('\r\n')
++ index = buf.find(b'\r\n')
+ if index >= 0:
+ break
+ data = recv(4096)
+@@ -1378,8 +1431,11 @@ def readline(self, raise_exception=False):
+
+ def expect(self, text, raise_exception=False):
+ line = self.readline(raise_exception)
+- if line != text:
+- self.debuglog("while expecting '%s', got unexpected response '%s'"
++ if self.debug and line != text:
++ if six.PY3:
++ text = text.decode('utf8')
++ line = line.decode('utf8', 'replace')
++ self.debuglog("while expecting %r, got unexpected response %r"
+ % (text, line))
+ return line
+
+@@ -1397,7 +1453,7 @@ def recv(self, rlen):
+
+ def flush(self):
+ self.send_cmd('flush_all')
+- self.expect('OK')
++ self.expect(b'OK')
+
+ def __str__(self):
+ d = ''
+@@ -1469,7 +1525,11 @@ def __eq__(self, other):
+ test_setget("a_string_2", "some random string", noreply=True)
+ test_setget("an_integer", 42)
+ test_setget("an_integer_2", 42, noreply=True)
+- if test_setget("long", long(1 << 30)):
++ if six.PY3:
++ ok = test_setget("long", 1 << 30)
++ else:
++ ok = test_setget("long", long(1 << 30))
++ if ok:
+ print("Testing delete ...", end=" ")
+ if mc.delete("long"):
+ print("OK")
+diff --git a/setup.py b/setup.py
+index 2a01f84..f105bf2 100644
+--- a/setup.py
++++ b/setup.py
+@@ -27,8 +27,8 @@
+ "Programming Language :: Python :: 2",
+ "Programming Language :: Python :: 2.6",
+ "Programming Language :: Python :: 2.7",
+-# "Programming Language :: Python :: 3",
+-# "Programming Language :: Python :: 3.2",
+-# "Programming Language :: Python :: 3.3",
+-# "Programming Language :: Python :: 3.4"
++ "Programming Language :: Python :: 3",
++ "Programming Language :: Python :: 3.2",
++ "Programming Language :: Python :: 3.3",
++ "Programming Language :: Python :: 3.4"
+ ])
+diff --git a/tests/test_memcache.py b/tests/test_memcache.py
+index c12c528..e5c833a 100644
+--- a/tests/test_memcache.py
++++ b/tests/test_memcache.py
+@@ -2,6 +2,8 @@
+
+ from unittest import TestCase
+
++import six
++
+ from memcache import Client, SERVER_MAX_KEY_LENGTH
+
+ try:
+@@ -135,14 +137,14 @@ def test_sending_key_too_long(self):
+
+ print("Testing sending a unicode-string key...", end=" ")
+ try:
+- x = mc.set(u'keyhere', 1)
++ x = mc.set(six.u('keyhere'), 1)
+ except Client.MemcachedStringEncodingError as msg:
+ print("OK", end=" ")
+ else:
+ print("FAIL", end=" ")
+ failures += 1
+ try:
+- x = mc.set((u'a'*SERVER_MAX_KEY_LENGTH).encode('utf-8'), 1)
++ x = mc.set((six.u('a')*SERVER_MAX_KEY_LENGTH).encode('utf-8'), 1)
+ except Client.MemcachedKeyError:
+ print("FAIL", end=" ")
+ failures += 1
+diff --git a/tests/test_setmulti.py b/tests/test_setmulti.py
+index cd06b04..2f7108a 100644
+--- a/tests/test_setmulti.py
++++ b/tests/test_setmulti.py
+@@ -21,7 +21,7 @@
+
+ class test_Memcached_Set_Multi(unittest.TestCase):
+ def setUp(self):
+- RECV_CHUNKS = ['chunk1']
++ RECV_CHUNKS = [b'chunk1']
+
+ class FakeSocket(object):
+ def __init__(self, *args):
Added: packages/python-memcache/trunk/debian/patches/series
===================================================================
--- packages/python-memcache/trunk/debian/patches/series (rev 0)
+++ packages/python-memcache/trunk/debian/patches/series 2015-04-23 22:43:46 UTC (rev 32412)
@@ -0,0 +1,2 @@
+port-memcache-to-python3.patch
+using-port-11212-instead-of-standard-11211.patch
Added: packages/python-memcache/trunk/debian/patches/using-port-11212-instead-of-standard-11211.patch
===================================================================
--- packages/python-memcache/trunk/debian/patches/using-port-11212-instead-of-standard-11211.patch (rev 0)
+++ packages/python-memcache/trunk/debian/patches/using-port-11212-instead-of-standard-11211.patch 2015-04-23 22:43:46 UTC (rev 32412)
@@ -0,0 +1,19 @@
+Description: Do not use memcache standard port
+ Because of the way we run tests in Debian, it's advised not to use the
+ standard port of memcached, so we can run another (test specific) instance
+ of memcached.
+Author: Thomas Goirand <zigo at debian.org>
+Forwarded: not-needed
+Last-Update: 2015-04-24
+
+--- python-memcache-1.54+20150423+git+48e882719c.orig/tests/test_memcache.py
++++ python-memcache-1.54+20150423+git+48e882719c/tests/test_memcache.py
+@@ -35,7 +35,7 @@ class FooStruct(object):
+ class TestMemcache(TestCase):
+ def setUp(self):
+ # TODO: unix socket server stuff
+- servers = ["127.0.0.1:11211"]
++ servers = ["127.0.0.1:11212"]
+ self.mc = Client(servers, debug=1)
+ pass
+
Modified: packages/python-memcache/trunk/debian/rules
===================================================================
--- packages/python-memcache/trunk/debian/rules 2015-04-23 22:24:27 UTC (rev 32411)
+++ packages/python-memcache/trunk/debian/rules 2015-04-23 22:43:46 UTC (rev 32412)
@@ -17,7 +17,25 @@
python$$pyvers setup.py install --install-layout=deb \
--root $(CURDIR)/debian/python3-memcache; \
done
+ rm -rf $(CURDIR)/debian/python*/usr/lib/python*/dist-packages/*.pth
+override_dh_auto_test:
+ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
+ chmod +x debian/setup-test-env-memcached.sh
+ debian/setup-test-env-memcached.sh nosetests -v
+ debian/setup-test-env-memcached.sh nosetests3 -v
+endif
+
override_dh_clean:
dh_clean -O--buildsystem=python_distutils
rm -rf Makefile build
+
+# Commands not to run
+override_dh_installcatalogs:
+override_dh_installemacsen override_dh_installifupdown:
+override_dh_installinfo override_dh_installmenu override_dh_installmime:
+override_dh_installmodules override_dh_installlogcheck:
+override_dh_installpam override_dh_installppp override_dh_installudev override_dh_installwm:
+override_dh_installxfonts override_dh_gconf override_dh_icons override_dh_perl override_dh_usrlocal:
+override_dh_installcron override_dh_installdebconf:
+override_dh_installlogrotate override_dh_installgsettings:
Added: packages/python-memcache/trunk/debian/setup-test-env-memcached.sh
===================================================================
--- packages/python-memcache/trunk/debian/setup-test-env-memcached.sh (rev 0)
+++ packages/python-memcache/trunk/debian/setup-test-env-memcached.sh 2015-04-23 22:43:46 UTC (rev 32412)
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -e
+set -x
+
+clean_exit () {
+ kill ${PID_OF_MEMCACHE}
+ sleep 1
+}
+
+wait_for_line () {
+ while read line ; do
+ echo "$line" | grep -q "$1" && break
+ done < "$2"
+ # Read the fifo for ever otherwise process would block
+ cat "$2" >/dev/null &
+}
+
+trap clean_exit EXIT
+/usr/bin/memcached -m 64 -p 11212 -u memcache -l 127.0.0.1 & PID_OF_MEMCACHE=$!
+sleep 2
+
+$@
Property changes on: packages/python-memcache/trunk/debian/setup-test-env-memcached.sh
___________________________________________________________________
Added: svn:executable
+ *
More information about the Python-modules-commits
mailing list