Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port memcache to Python 3 #67

Merged
merged 1 commit into from Jul 26, 2015

Conversation

@vstinner
Copy link
Contributor

commented Apr 23, 2015

  • 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
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
@vstinner

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2015

I modified my patch to add Python 3 classifiers in setup.py, make Python 3 tests voting on Travis and I fixed Python 3.2 syntax in tests using six.u('...').

I saw a lot of Python 3 fixes merged in 2014. They changes are part of the release 1.54. Great!

"import memcache" works, but "tox -e py34" fails badly. I get obvious Python 3 errors like:

======================================================================
ERROR: test_setget_foostruct (test_memcache.TestMemcache)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/haypo/prog/openstack/python-memcached/tests/test_memcache.py", line 69, in test_setget_foostruct
    self.check_setget("foostruct", f)
  File "/home/haypo/prog/openstack/python-memcached/tests/test_memcache.py", line 41, in check_setget
    self.mc.set(key, val, noreply=noreply)
  File "/home/haypo/prog/openstack/python-memcached/memcache.py", line 674, in set
    return self._set("set", key, val, time, min_compress_len, noreply)
  File "/home/haypo/prog/openstack/python-memcached/memcache.py", line 975, in _set
    return _unsafe_set()
  File "/home/haypo/prog/openstack/python-memcached/memcache.py", line 944, in _unsafe_set
    store_info = self._val_to_store_info(val, min_compress_len)
  File "/home/haypo/prog/openstack/python-memcached/memcache.py", line 899, in _val_to_store_info
    elif isinstance(val, long):
NameError: name 'long' is not defined

Did I miss something or python-memcached 1.54 does not support Python 3?

py27 and py34 tox tests pass with this pull request.

@vstinner

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2015

Travis confirms what I saw on my PC: tests now pass on Python 2.6, 2.7, 3.2, 3.3 and 3.4 (and PyPy), great!

@vstinner

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2015

This pull request is related to the issue #48.

@gilgamezh gilgamezh referenced this pull request May 2, 2015
@gilgamezh

This comment has been minimized.

Copy link

commented May 2, 2015

👍
Related to #54

@Haypo Check https://github.com/linsomniac/python-memcached/pull/68/files#diff-894c02c873c7b32549152655db8797a8R62

My branch is working with python3.4 (but yours is really better! )

Forget it. Is already solved 😄

@vstinner

This comment has been minimized.

Copy link
Contributor Author

commented May 2, 2015

Hi @linsomniac, could you please review my Python 3 pull request? Last September you wrote "'m going to need someone to formulate a patch for this, I'm not having any luck resolving it." Here you have.

@vstinner

This comment has been minimized.

Copy link
Contributor Author

commented May 14, 2015

ping?

@tgy

This comment has been minimized.

Copy link

commented May 20, 2015

ping again? I need this too!
(and thanks @Haypo)

@willhcr

This comment has been minimized.

Copy link

commented Jun 7, 2015

Would be great to see this merged. We're currently using python3-memached but it doesn't have any unit tests or CI setup, so looking forward to official support.

@OrCharles

This comment has been minimized.

Copy link

commented Jun 9, 2015

@linsomniac ping, would really appreciate having this patched into the next release

@andyboxer

This comment has been minimized.

Copy link

commented Jun 14, 2015

@linsomniac This is great thanks to @Haypo
This resolves issues for me whilst porting some stuff to python3.4
Is there a reason this can't be merged? or should we consider @Haypo as definitive for 3.4?

@thomasgoirand

This comment has been minimized.

Copy link

commented Jun 17, 2015

ping? Could we please get this pull request in, and a new version released?

@thomasgoirand

This comment has been minimized.

Copy link

commented Jul 5, 2015

Still no reply? It'd be nice if you could either: 1/ get this merged and release a new version of the package in PyPi, or 2/ declare the package as unmaintained and ask if someone wants to take over the maintenance, or at least allow to have co-maintainers (co-maintaining is always a good practice anyway). Because waiting for more than 2 months and a half for such a pull request without even answering in this thread is really too much.

@tgy

This comment has been minimized.

Copy link

commented Jul 5, 2015

On Sun, Jul 05, 2015 at 11:06:47AM -0700, Thomas Goirand wrote:

waiting for more than 2 months and a half for such a pull request
without even answering in this thread is really too much.

I agree.

@dims

This comment has been minimized.

Copy link

commented Jul 16, 2015

+1 we are hitting this in keystone (https://review.openstack.org/#/c/177661/)

openstack-gerrit pushed a commit to openstack/requirements that referenced this pull request Jul 24, 2015
No-python3 classifier for python-memcached
python-memcached doesn't support py34. keystonemiddleware py34 unit
tests fail with an error using python-memcached:

...
  File "/opt/stack/keystonemiddleware/.tox/py34/lib/python3.4/site-packages/memcache.py", line 1299, in send_cmd
    self.socket.sendall(cmd + '\r\n')
TypeError: 'str' does not support the buffer interface

This issue is reported to python-memcached:
linsomniac/python-memcached#70

There's a pull request:
linsomniac/python-memcached#67

Looks like python-memcached is an abandoned project.

Change-Id: Ie3dacedc9a355be914fe30f16dc40c58f779c46b
openstack-gerrit added a commit to openstack/openstack that referenced this pull request Jul 24, 2015
Updated openstack/openstack
Project: openstack/requirements  d502a6e23a26c60cb699b3aa5c11e010d8eceb13

No-python3 classifier for python-memcached

python-memcached doesn't support py34. keystonemiddleware py34 unit
tests fail with an error using python-memcached:

...
  File "/opt/stack/keystonemiddleware/.tox/py34/lib/python3.4/site-packages/memcache.py", line 1299, in send_cmd
    self.socket.sendall(cmd + '\r\n')
TypeError: 'str' does not support the buffer interface

This issue is reported to python-memcached:
linsomniac/python-memcached#70

There's a pull request:
linsomniac/python-memcached#67

Looks like python-memcached is an abandoned project.

Change-Id: Ie3dacedc9a355be914fe30f16dc40c58f779c46b
openstack-gerrit added a commit to openstack/openstack that referenced this pull request Jul 24, 2015
Updated openstack/openstack
Project: openstack/requirements  d502a6e23a26c60cb699b3aa5c11e010d8eceb13

No-python3 classifier for python-memcached

python-memcached doesn't support py34. keystonemiddleware py34 unit
tests fail with an error using python-memcached:

...
  File "/opt/stack/keystonemiddleware/.tox/py34/lib/python3.4/site-packages/memcache.py", line 1299, in send_cmd
    self.socket.sendall(cmd + '\r\n')
TypeError: 'str' does not support the buffer interface

This issue is reported to python-memcached:
linsomniac/python-memcached#70

There's a pull request:
linsomniac/python-memcached#67

Looks like python-memcached is an abandoned project.

Change-Id: Ie3dacedc9a355be914fe30f16dc40c58f779c46b
linsomniac added a commit that referenced this pull request Jul 26, 2015
Merge pull request #67 from haypo/py3
Port memcache to Python 3

@linsomniac linsomniac merged commit 7e353b8 into linsomniac:master Jul 26, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dims

This comment has been minimized.

Copy link

commented Jul 26, 2015

Thanks a ton @linsomniac !

@gilgamezh

This comment has been minimized.

Copy link

commented Jul 27, 2015

👏 👏

@vstinner vstinner deleted the vstinner:py3 branch Jul 27, 2015

openstack-gerrit pushed a commit to openstack/requirements that referenced this pull request Jul 27, 2015
Allow new python-memcached version - 1.56
1.56 python-memcached has support for python2.7 + python3.4
thanks to @haypos' patch:
linsomniac/python-memcached#67

oslo.cache really needs this newer version for py34 release.

Change-Id: If8fc758d8a7d918e151ab7014d4c6fadfb0fce61
openstack-gerrit added a commit to openstack/openstack that referenced this pull request Jul 27, 2015
Updated openstack/openstack
Project: openstack/requirements  562f44685d412b4ba082267f4cbe83ae63256e0c

Allow new python-memcached version - 1.56

1.56 python-memcached has support for python2.7 + python3.4
thanks to @haypos' patch:
linsomniac/python-memcached#67

oslo.cache really needs this newer version for py34 release.

Change-Id: If8fc758d8a7d918e151ab7014d4c6fadfb0fce61
openstack-gerrit added a commit to openstack/openstack that referenced this pull request Jul 27, 2015
Updated openstack/openstack
Project: openstack/requirements  562f44685d412b4ba082267f4cbe83ae63256e0c

Allow new python-memcached version - 1.56

1.56 python-memcached has support for python2.7 + python3.4
thanks to @haypos' patch:
linsomniac/python-memcached#67

oslo.cache really needs this newer version for py34 release.

Change-Id: If8fc758d8a7d918e151ab7014d4c6fadfb0fce61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.