#23333 closed Bug (fixed)
urlsafe_base64_encode/decode don't round-trip on python3
| Reported by: | Ian Foote | Owned by: | Ian Foote | 
|---|---|---|---|
| Component: | Utilities | Version: | dev | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | yes | UI/UX: | no | 
Description
The functions urlsafe_base64_encode and urlsafe_base64_decode in django.utils.http should be inverses of each other, but on python3 urlsafe_base64_encode returns bytes but urlsafe_base64_decode expects a str. I've created a test for this on a github branch.
Change History (8)
comment:1 by , 11 years ago
| Easy pickings: | set | 
|---|---|
| Triage Stage: | Unreviewed → Accepted | 
comment:2 by , 11 years ago
I've updated my branch with your suggested fix and created a pull request.
comment:3 by , 11 years ago
| Has patch: | set | 
|---|---|
| Owner: | changed from to | 
| Status: | new → assigned | 
comment:4 by , 11 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
comment:6 by , 11 years ago
As a bug in a new feature in 1.6, yes. However, after the release of 1.7, 1.6 is only receiving security fixes so I think we should do 1.7 only.
  Note:
 See   TracTickets
 for help on using tickets.
    
Confirmed. The solution is probably to use
django.utils.encoding.force_bytesinstead of callingencodedirectly.