Code

Changes between Version 4 and Version 5 of PortingNotesFor2To3


Ignore:
Timestamp:
12/10/11 06:12:15 (2 years ago)
Author:
vsajip
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortingNotesFor2To3

    v4 v5  
    6464* If you see `xrange` in the source, just do `from django.utils.py3 import xrange`. 
    6565 
    66 * If you use anything from `urllib`, `urllib2`, `urlparse`, you will need to import them  
     66* If you use anything from `urllib`, `urllib2`, `urlparse`, you will need to import the actual functions from `django.utils.py3`. 
     67  You can grep the instances of those calls in the ported Django code to see how it's done. 
     68 
     69* If you're using `StringIO` or `BytesIO`, import them from `django.utils.py3`. 
     70 
     71* If a class has a `next()` method which is used for iteration, add a line `__next__ = next` just after it in the class. If it has 
     72  a `__nonzero__` method, add `__bool__ = __nonzero` in the same way. Where you see `x.next()` used to iterate, do 
     73  `from django.utils.py3 import next` and replace using the pattern `x.next()` -> `next(x)` (where `x` might be an expression 
     74  rather than just a name). 
     75 
     76* If you define rich comparisons, review how they work in 2.x and 3.x and adapt your code accordingly.