Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd Python 3 compatibility #32
Conversation
dan-blanchard
added some commits
Jul 10, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
amontalenti
Jul 11, 2014
Member
This looks really nice and complete, @dan-blanchard. Thank you for the contribution. We'll make sure to review in detail tomorrow and assuming all is good, we'll merge promptly and cut a release!
|
This looks really nice and complete, @dan-blanchard. Thank you for the contribution. We'll make sure to review in detail tomorrow and assuming all is good, we'll merge promptly and cut a release! |
dfdeshom
reviewed
Jul 11, 2014
View changes
setup.py
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Jul 11, 2014
Member
I've switched to using a regular expression for extracting the version number like you suggested.
|
I've switched to using a regular expression for extracting the version number like you suggested. |
amontalenti
reviewed
Jul 11, 2014
View changes
README.rst
amontalenti
reviewed
Jul 11, 2014
| _stdout.buffer.flush() | ||
| _stdout.buffer.write(wrapped_msg) | ||
| else: | ||
| _stdout.write(wrapped_msg) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
amontalenti
Jul 11, 2014
Member
This is an interesting branch. Why is it that in Py3 we need to flush first?
amontalenti
Jul 11, 2014
Member
This is an interesting branch. Why is it that in Py3 we need to flush first?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Jul 11, 2014
Member
I'm just being extra cautious. On Python 3 you can't write bytes directly to sys.stdout, but you can write to the underlying buffer, which is what I'm doing.
I cannot for the life of me find where I saw it, but somewhere I had read that when writing to the buffer directly, you should always flush first in case there are str things buffered (from using sys.stdout.write directly). In our case, I'm not sure that would ever happen, but I was just trying to be safe.
We can certainly take it out if you think it could cause performance issues or something.
dan-blanchard
Jul 11, 2014
Member
I'm just being extra cautious. On Python 3 you can't write bytes directly to sys.stdout, but you can write to the underlying buffer, which is what I'm doing.
I cannot for the life of me find where I saw it, but somewhere I had read that when writing to the buffer directly, you should always flush first in case there are str things buffered (from using sys.stdout.write directly). In our case, I'm not sure that would ever happen, but I was just trying to be safe.
We can certainly take it out if you think it could cause performance issues or something.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
amontalenti
Jul 11, 2014
Member
Ah hah, interesting. I didn't know about this buffer vs direct writing difference between 2 and 3.
The official docs say:
if you are writing a library (and do not control in which context its code will be executed), be aware that the standard streams may be replaced with file-like objects like io.StringIO which do not support the buffer attribute.
But I guess in this situation, we do "control the environment", so checking for the existence of buffer isn't necessary. I think your code is good as-is, let's go with that.
amontalenti
Jul 11, 2014
Member
Ah hah, interesting. I didn't know about this buffer vs direct writing difference between 2 and 3.
The official docs say:
if you are writing a library (and do not control in which context its code will be executed), be aware that the standard streams may be replaced with file-like objects like io.StringIO which do not support the buffer attribute.
But I guess in this situation, we do "control the environment", so checking for the existence of buffer isn't necessary. I think your code is good as-is, let's go with that.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
amontalenti
Jul 11, 2014
Member
I reviewed and everything looks good to me. @msukmanowsky if you approve, I'll merge this.
|
I reviewed and everything looks good to me. @msukmanowsky if you approve, I'll merge this. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Jul 11, 2014
Member
Just noticed one remaining issue: SocketServer instead of socketserver in contextmanagers.py. I'll fix that.
|
Just noticed one remaining issue: |
dan-blanchard
added some commits
Jul 11, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Okay, that should be fixed now. |
msukmanowsky
reviewed
Jul 11, 2014
View changes
setup.py
msukmanowsky
reviewed
Jul 11, 2014
View changes
setup.py
msukmanowsky
reviewed
Jul 11, 2014
| @@ -226,7 +245,7 @@ def process_batch(self, key, tups): | ||
| """ | ||
| raise NotImplementedError() | ||
| def _batcher(self): | ||
| def _batch_entry(self): |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Jul 12, 2014
Member
_batcher is still the name of thread, it's just that now there's no longer a naming clash where there is an attribute called _batcher that is a thread and a method called _batcher. Now the _batcher thread runs the _batch_entry method. I'm not sure the doc strings need to be updated. It depends on whether you think they should be talking about the method or the thread.
dan-blanchard
Jul 12, 2014
Member
_batcher is still the name of thread, it's just that now there's no longer a naming clash where there is an attribute called _batcher that is a thread and a method called _batcher. Now the _batcher thread runs the _batch_entry method. I'm not sure the doc strings need to be updated. It depends on whether you think they should be talking about the method or the thread.
msukmanowsky
reviewed
Jul 11, 2014
View changes
streamparse/bolt.py
msukmanowsky
reviewed
Jul 11, 2014
| @@ -69,17 +69,17 @@ def test_3_multi_ack(self): | ||
| "task": 0, | ||
| "tuple": ["snow white and the seven dwarfs", "field2", 3, 4.252], | ||
| } | ||
| for i in xrange(5): | ||
| for i in range(5): |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
msukmanowsky
Jul 11, 2014
Member
Is there a six import we can do for the xrange -> range conversion? Minor thing.
msukmanowsky
Jul 11, 2014
Member
Is there a six import we can do for the xrange -> range conversion? Minor thing.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Jul 11, 2014
Member
Yes, six does have such a thing. I figured it didn't really matter since it was only 5 items, but I'll switch to using six.
dan-blanchard
Jul 11, 2014
Member
Yes, six does have such a thing. I figured it didn't really matter since it was only 5 items, but I'll switch to using six.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
msukmanowsky
Jul 11, 2014
Member
Had a look through @dan-blanchard and overall, things look great! Just a few small knitpicks really. Thanks for moving streamparse into the future! :)
|
Had a look through @dan-blanchard and overall, things look great! Just a few small knitpicks really. Thanks for moving streamparse into the future! :) |
dan-blanchard
added some commits
Jul 12, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Jul 12, 2014
Member
I made all the requested changes (except for the batcher thing, which I've commented on above).
|
I made all the requested changes (except for the batcher thing, which I've commented on above). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Awesome! Thanks again @dan-blanchard, great work and contribution. |
added a commit
that referenced
this pull request
Jul 12, 2014
msukmanowsky
merged commit 011c670
into
Parsely:master
Jul 12, 2014
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
amontalenti
Jul 17, 2014
Member
@dan-blanchard @msukmanowsky sorry for the delay on this, but I did cut a new streamparse release, 0.0.13, that includes Storm 0.9.2 support & Python 3 support. https://github.com/Parsely/streamparse/releases/tag/v0.0.13 (it's up on PyPI and the Clojar dependency has been updated, too)
|
@dan-blanchard @msukmanowsky sorry for the delay on this, but I did cut a new streamparse release, 0.0.13, that includes Storm 0.9.2 support & Python 3 support. https://github.com/Parsely/streamparse/releases/tag/v0.0.13 (it's up on PyPI and the Clojar dependency has been updated, too) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thanks @amontalenti! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
apogre
commented on e288785
Mar 31, 2015
|
Trouble of python 2.7 users!! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
dan-blanchard
Mar 31, 2015
Member
Is this actually not working for you on 2.7? We're using six to make sure this works with both.
|
Is this actually not working for you on 2.7? We're using six to make sure this works with both. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
apogre
replied
Mar 31, 2015
|
yeah, I had to change it to older version to get it running on 2.7 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Could you please file an issue with a stacktrace? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
apogre
replied
Mar 31, 2015
|
out of workstation. Will do it tomorrow! |
dan-blanchard commentedJul 11, 2014
This PR makes streamparse Python 3 compatible (issue #9) by:
iteritemsandreraisefrom __future__ import absolute_import, print_function, unicode_literalsto the top of nearly every.pyfile.printstatements withprintfunctions..travis.yml.unittest2fromtest_requireswhen on Python 3.I also fixed a few pylint issues and other general correctness things like:
[]and{}as default arguments as to avoid this nonsense.streamparsefor__version__insetup.pyto fix potential issues where the user doesn't have all prereqs already installed.README.rstinstead ofREADME.mdand madesetup.pyautomatically use that as thelong_descriptionfor PyPI.I have not extensively tested this beyond making sure all the unit tests pass on 2.7 and 3.3 on Travis, so let me know if I missed something.