#18706: django.utils.http.int_to_base36 raises ValueError instead of TypeError 
for
invalid input
----------------------------------------+------------------------
               Reporter:  aaugustin     |          Owner:  nobody
                   Type:  Bug           |         Status:  new
              Component:  Core (Other)  |        Version:  master
               Severity:  Normal        |       Keywords:
           Triage Stage:  Unreviewed    |      Has patch:  0
    Needs documentation:  0             |    Needs tests:  0
Patch needs improvement:  0             |  Easy pickings:  0
                  UI/UX:  0             |
----------------------------------------+------------------------
 This behavior seems wrong to me, and unfortunately,
 
[https://github.com/django/django/blob/master/tests/regressiontests/utils/http.py#L117
 it's tested].

 Keeping it in Python 3 is needlessly complicated. Python 3 will rightly
 raise a `TypeError` for invalid comparisons. Catching it and re-raising a
 less appropriate `ValueError` seems just wrong to me.



 Python 2:
 {{{
 >>> 0 <= '' <= 2**31 - 1
 False
 }}}

 Python 3:
 {{{
 >>> 0 <= '' <= 2**31 - 1
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 TypeError: unorderable types: int() <= str()
 }}}

 I'm attaching a patch that adds Python 3 compatibility (we can't use
 `sys.maxint` any longer) and improves the handling of invalid inputs under
 Python 2.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18706>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to