Opened 3 years ago

Closed 3 years ago

#16942 closed Bug (fixed)

utils.htp.int_to_base36 explicit cast to int

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

Description

int_to_base36 uses the result of a division as an index into a string. In Python 3 division return a float not an int. So explicitly cast the result to an int.

Attachments (2)

fix-int_to_base36-division.patch (421 bytes) - added by adsworth 3 years ago.
16942-use-integer-divison.patch (417 bytes) - added by adsworth 3 years ago.

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by adsworth

comment:1 Changed 3 years ago by andreas_pelme

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

It is also possible to use the integer division operator //. This could need a test case, it would be easy to test it.

comment:2 Changed 3 years ago by anonymous

I came across this because of the failing test: test_custom_email_subject (django.contrib.auth.tests.forms.PasswordResetFormTest)
This fails when run with Python3.

Do you still want a test case?

I'll add a patch using in the next couple of days.

comment:3 Changed 3 years ago by adsworth

The previous comment was from me. For some reason I wasn't logged in.

Changed 3 years ago by adsworth

comment:4 Changed 3 years ago by adsworth

Attached a new patch using integer division.

Does this really need a separate test case?

comment:5 Changed 3 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top