Conversation
@@ -401,7 +402,7 @@ def elements(self): | |||
""" | |||
for element, count in self._data(): | |||
if count: | |||
for _ in xrange(0, count): | |||
for _ in range(0, count): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But range in Python 2.X is not the same as range in Python 3.X, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I wasn't precise enough :) There's fix in a0d966b
Seems like a good work, thanks! Usage of One serious issue: I am afraid I can't maintain the project in multiple versions. I'd appreciate any help with all this. It is a kind of challenge for me, I can't just learn it in one day and then be ready to fix bugs and run tests on such "dual" codebase. |
The article, you've mentioned, implements similar constructs as six does. The good think about six is, you mantain only one codebase. Sure, you have to test new code agains multiple versions, but I'm willing to help you with that since I'm going to use this library. |
@@ -366,7 +370,7 @@ def __init__(self, *args, **kwargs): | |||
super(Counter, self).__init__(*args, **kwargs) | |||
|
|||
def _pickle(self, data): | |||
return unicode(int(data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what is purpose of this line. Test suite passes even with identity function (return data
). Why you convert data
to int and then to unicode? I'm asking because my "fix" isn't precise either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is type check (int
) and serialization (unicode
). In this implementation of Counter
, data has to be integer only and then they are serialized for Redis just by calling unicode
. Maybe it involves some redundancy, but it is improving readability and consistency. I agree coercing to int
is stupid "validation", but it did the job quite well so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure. If int
is called as type check only, it would work. There's no unicode
in Py3 and "it works" even without it. I'll try to fix it so it reflects original behavior.
Edit: Added d873e1a
If you agree to take care about the PY3 version and compatibility testing, I am open to accept your changes regardless your tools ( |
Sure, I'm in. As I said, I'm going to use Py3 version, from your official repository or forked one. Who uses Python 2.x these days anyway? :) |
Me! :-D |
|
I think I should write tests, which could possibly break your PY3 port and if they won't, I can merge it :-) That's probably the best idea for now. |
There's no rush. I still haven't used it in production. That would be definitely good source for bugs and tests. |
Actually, there is. I got some e-mails about PY3 support from other people :) |
I'm willing to use this with PY3 as well. I get basestring errors, (NameError: global name 'basestring' is not defined) the following proposes a solution (which has more or less been mentioned above): oxplot/fysom#1 |
+1 for basestring errors
>>> from redis_collections import List
>>> a = List(key='test')
>>> a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/scollins/src/vote_rings/.venv/lib/python3.3/site-packages/redis_collections/base.py", line 296, in __repr__
data = self._repr_data(self._data())
File "/Users/scollins/src/vote_rings/.venv/lib/python3.3/site-packages/redis_collections/lists.py", line 361, in _repr_data
return repr(list(data))
File "/Users/scollins/src/vote_rings/.venv/lib/python3.3/site-packages/redis_collections/lists.py", line 74, in <genexpr>
return (self._unpickle(v) for v in values)
File "/Users/scollins/src/vote_rings/.venv/lib/python3.3/site-packages/redis_collections/base.py", line 225, in _unpickle
if not isinstance(string, basestring):
NameError: global name 'basestring' is not defined |
+1 for this - Same error here, it makes this module unusable for me in its current state. |
I don't have time (motivation) currently to maintain |
@tricoder42, I'm going to close this PR in favor of #44, which similarly moves toward supporting Python 3. Thanks! |
Added Python2/3 compatability layer through six. Tests pass on python 2.7, 3.2, 3.3.