How CherryPy supports Python 2 and 3

Audience level:
Core Python (Language, Stdlib)
March 10th 4:55 p.m. – 5:30 p.m.


CherryPy was the first web framework to be made available for use with Python 3, and we tried several approaches to support both Python 2 and 3 before settling on one. Learn about the ups and the downs of each approach, and ways you can make your own porting project easier.


The CherryPy project was the first web framework to support Python 3. At the same time, we needed to continue to support and improve the Python 2 implementation. It's taken plenty of time and lots of experimentation to find out the best way. We will explore four different ways to support both Python 2 and 3, commenting on the pros and cons of each.

  1. Intro
  2. Python 3 change highlights
  3. Special concerns for I/O, including WSGI
  4. Approach 1: 2to3
  5. Approach 2: separate branches
  6. Approach 3: switch
  7. Approach 4: compatibility layer
  8. Q&A