Python 2to3: Difference between revisions
mNo edit summary |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 17: | Line 17: | ||
: Target: Should be compatible with both Python 2 and Python 3, to support the large number of activities currently in Python 2 | : Target: Should be compatible with both Python 2 and Python 3, to support the large number of activities currently in Python 2 | ||
: WIP: https://github.com/Pro-Panda/sugar-toolkit-gtk3/tree/python3-port | : WIP: https://github.com/Pro-Panda/sugar-toolkit-gtk3/tree/python3-port | ||
: Status: Mostly | : Status: Mostly Complete; what remains is an entire project in itself of [https://github.com/orgs/sugarlabs/projects/4 porting the Telepathy Bindings]. | ||
: Critical changes implelmented: | |||
:* Python 3 activities must be instantiated with sugar-activity3 instead of sugar-activity | |||
:* sugar-activity-web will call the Python 3 version of the toolkit and will be installed only with the same | |||
:* warning logged if activity is not ported to Python 3 | |||
Note: To test the toolkit without porting the telepathy bindings, please use the Python 3 bindings (not for release), https://github.com/pro-panda/telepathy3 | |||
;Sugar-Datastore | ;Sugar-Datastore | ||
| Line 30: | Line 36: | ||
;Sugar Desktop Activities | ;Sugar Desktop Activities | ||
: Guide to porting activities to Python 3 is [https://github.com/sugarlabs/sugar-docs/blob/master/src/python-porting-guide.md here] | |||
{| style="text-align: center;" | {| style="text-align: center;" | ||
! | Activity | ! | Activity | ||
| Line 112: | Line 118: | ||
There are several ways of contributing to the project | There are several ways of contributing to the project | ||
; Port Telepathy bindings | ; Port Telepathy bindings | ||
: Telepathy does not have python | : Telepathy does not have python 3 bindings and needs to be ported to its PyGObject bindings as a prerequisite for porting to Python 3 | ||
: See https://github.com/orgs/sugarlabs/projects/4 | : See https://github.com/orgs/sugarlabs/projects/4 | ||
| Line 128: | Line 134: | ||
: Sugar and the components lack in testing mechanisms and scripts. Our current test coverage is very basic and minimal. Improving the same is critical and the best time would be to so while Porting and testing the components | : Sugar and the components lack in testing mechanisms and scripts. Our current test coverage is very basic and minimal. Improving the same is critical and the best time would be to so while Porting and testing the components | ||
: Some test scripts are here - https://github.com/Pro-Panda/sugar-python3-tests | : Some test scripts are here - https://github.com/Pro-Panda/sugar-python3-tests | ||
== Notes == | |||
* httplib.HTTP is not available in Python 3; use http.client.HTTPConnection instead | |||
* cmp function does not exist in Python 3, use the cmp_to_key function; see https://docs.python.org/3/howto/sorting.html#sortinghowto | |||
* list.sort function requires named parameters in Python 3 | |||
* hashlib.md5 requires bytes as an argument in Python 3 | |||
* sha_hash.update requires bytes as an argument in Python 3 | |||
* statvfs does not exist in Python 3, verify the Python 2 constant values and use them instead | |||