-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: code compatible with python2 and python3 #136
Conversation
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.
LGTM
@imZack any comment ?
LGTM However, are all the modules in the requirements support Python 3? |
.travis.yml
Outdated
@@ -6,7 +6,7 @@ install: | |||
script: make tox | |||
env: | |||
- TOXENV=py27 | |||
- TOXENV=pypy | |||
- TOXENV=py36 |
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.
The modifications will make pypy
failed? Otherwise, maybe we can just add one more entry without removing pypy
setup.py
Outdated
@@ -29,6 +29,8 @@ def read(*paths): | |||
'Programming Language :: Python :: 2', | |||
'Programming Language :: Python :: 2.6', | |||
'Programming Language :: Python :: 2.7', | |||
'Programming Language :: Python :: 3', | |||
'Programming Language :: Python :: 3.6', |
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.
FYI --
https://wiki.debian.org/Python
Debian 9 uses Python 3.5 and Debian 10 uses Python 3.7
@imZack I think the py36 test run pass, means the modules in requirements.txt support Python 3. |
@taotao yes but something like paho-mqtt we probably need to check again. It's not in the test. |
@imZack after testing with sanji-examples the |
@imZack I found the root cause of this issue. I also find a issue, when we change the QoS from 2 to 0. (commit) |
@taotao Got it, yeah... The reason I've changed default QoS from 2 to 0 is mainly due to client/broker are on the same host. Do you have the script to reproduce 500 error? |
@imZack
|
@CPtung |
5463dea
to
01d0bd9
Compare
tests/sanji/test_core.py
Outdated
@@ -207,7 +207,7 @@ def test__dispatch_message(self): # noqa | |||
self.test_model._Sanji__dispatch_message(m) | |||
resp.assert_called_once_with( | |||
code=404, data={"message": ANY}) | |||
|
|||
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.
extra space~~~
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.
My fault...
@@ -134,8 +135,11 @@ def ___dispatch(handler, message): | |||
|
|||
try: | |||
for result in results: # same route | |||
map(lambda handler: ___dispatch(handler, result["message"]), | |||
data = map(lambda handler: ___dispatch( |
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.
why we need to get data
and list
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.
Map in Python2 will return a list object
but map object
in Python3. It causes the lambda should execute the handler to do the dispatch but nothing happened. Here I add a workaround which casts the map object to list, then the result becomes what we expect.
No description provided.