Python 2to3

From Sugar Labs
Jump to navigation Jump to search

Project Introduction

Sugar currently uses Python 2. Since support for python 2 is being drawn, we are porting our code to Python 3.

It is one of the goals for Sugar Labs for 2018, with a suggested timeframe of ~12-16 months for completing the project.

The project was taken up by Sugar Labs in Google Summer of Code 2018

Project Summary

The project progress can be tracked here.

Target: Port entirely to Python 3
Status: While some critical issues still persist, most of the functionality is running and tested.
Target: Should be compatible with both Python 2 and Python 3, to support the large number of activities currently in Python 2
Status: Mostly Complete; what remains is an entire project in itself of 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),

Target: Port entirely to Python 3
Status: Complete(possible fix patches do come up while porting sugar); Fedora packaging and testing remains
Target: Port entirely to Python 3 (use system empy bindings for Python 3)
Status: Complete; Fedora packaging and testing remains
Sugar Desktop Activities
Guide to porting activities to Python 3 is here
Activity Status [WIP/Ported] Pull Request
Log Ported PR link
JukeBox Ported PR link
Abacus Ported PR link
Calculate Ported PR link
Chat Ported PR link
CowBulls Ported PR link
Finance Ported PR link
Hello-world Ported PR link
Imageviewer Ported PR link
Read Ported PR link
Spirolaterals Ported PR link
Terminal Ported PR link
Write Ported PR link
Nutrition Ported PR link

Contributing to the Project

There are several ways of contributing to the project

Port Telepathy bindings
Telepathy does not have python 3 bindings and needs to be ported to its PyGObject bindings as a prerequisite for porting to Python 3
Test Debian Packages
Debian packages for core modules here:
Please install, test and report bugs, (or better, submit fix patches)
Fedora Packaging
Make Fedora packages of core modules (WIP links above) and test them
Port Sugar Desktop Activities to Python 3
See the guide to port activities to Python 3:
Improve test coverage
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 -


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