Opened 3 years ago

Closed 3 years ago

#18269 closed Cleanup/optimization (fixed)

From __future__ import unicode_literals

Reported by: claudep Owned by: nobody
Component: Python 3 Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


To the road to Python3, a possible next step would be to use the from __future__ import unicode_literals and remove the u'' prefixes, as it is not supported in Python3 (may be added in 3.3 for compatibility reasons).

I made a branch which has strong inspiration from Vinay Sajip Python3 branch of Django (

Change History (10)

comment:2 Changed 3 years ago by claudep

I know about PEP 414, however we must decide if we want to support 3.2 or not...

comment:3 Changed 3 years ago by anonymous

I thought that decision had bee made, in favor of supporting 3.2. In this message: from Carl Meyer:

I think the fact that the next Ubuntu LTS will include Python 3.2, and
it won't be possible to make use of PEP 314 on Python 3.2 without
install-time-transformation hacks, is a strong argument in favor of
sticking with a working unicode_literals port rather than reworking it
to use PEP 314.

I do not see any follow-up disagreeing with that position.

comment:4 Changed 3 years ago by kmtracey

Comment #3 was me.

comment:5 follow-up: Changed 3 years ago by aaugustin

If I understand correctly (far from granted in this area):

  • if we only support 3.3+, we can use u"" and b"" for unicode and bytes (resp.)
  • to support 3.2, we have to use "" and b""

This doesn't make a big difference, so I agree with Karen and Carl that we should support 3.2.

I suppose automatic tools exist to help the conversion?

comment:6 in reply to: ↑ 5 Changed 3 years ago by claudep

Replying to aaugustin:

I suppose automatic tools exist to help the conversion?

The conversion is already done (more or less automatically) in my branch (see link in the description).

comment:7 Changed 3 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

comment:8 Changed 3 years ago by Claude Paroz <claude@…>

In [38408f8007eae21b9f1cbbcc7f86d4b2042ff86a]:

Marked bytestrings with b prefix. Refs #18269

This is a preparation for unicode literals general usage in
Django (Python 3 compatibility).

comment:9 Changed 3 years ago by claudep

I just updated the branch (rebased) and created a pull request for better review:

comment:10 Changed 3 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In [4a103086d5c67fa4fcc53c106c9fdf644c742dd8]:

Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.

Thanks Vinay Sajip for the support of his django3 branch and
Jannis Leidel for the review.

Note: See TracTickets for help on using tickets.
Back to Top