#32508: Raise proper exceptions instead of using "assert".
--------------------------------------+------------------------------------
Reporter: Adam Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Jacob Walls):
Replying to [comment:22 Nishant Sagar]:
> May I take this ticket and if yes can anyone suggests me the ways to
proceed as I'm fairly new to this
Thanks for your interest. Daniyal handled the bulk of what was left here
in [https://github.com/django/django/pull/14173 PR 14173], so if you want
to tackle the rest, be sure to skip the django.db module, which was the
focus of that PR.
Toward getting started, this is a great time to learn about grep, e.g.
`grep 'assert\s' django/* -r`. Here's what's left excluding django.db and
the test suite itself:
{{{
django/contrib/auth/hashers.py: assert password is not None
django/contrib/auth/hashers.py: assert salt and '$' not in salt
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert password is not None
django/contrib/auth/hashers.py: assert salt and '$' not in salt
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert password is not None
django/contrib/auth/hashers.py: assert salt and '$' not in salt
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/hashers.py: assert salt == ''
django/contrib/auth/hashers.py: assert encoded.startswith('sha1$$')
django/contrib/auth/hashers.py: assert salt == ''
django/contrib/auth/hashers.py: assert len(salt) == 2
django/contrib/auth/hashers.py: assert hash is not None # A
platform like OpenBSD with a dummy crypt module.
django/contrib/auth/hashers.py: assert algorithm == self.algorithm
django/contrib/auth/views.py: assert 'uidb64' in kwargs and 'token'
in kwargs
django/contrib/staticfiles/storage.py: assert
url_path.startswith(settings.STATIC_URL)
django/dispatch/dispatcher.py: assert callable(receiver),
"Signal receivers must be callable."
django/http/multipartparser.py: assert remaining > 0,
'remaining bytes to read should never go negative'
django/test/client.py: assert self.__len >= num_bytes, "Cannot read
more than the available bytes from the HTTP incoming data."
django/test/utils.py: assert not kwargs
django/test/utils.py: assert not args
django/test/testcases.py: assert not self.reset_sequences,
'reset_sequences cannot be used on TestCase instances'
django/utils/version.py: assert len(version) == 5
django/utils/version.py: assert version[3] in ('alpha', 'beta',
'rc', 'final')
django/utils/regex_helper.py: assert not flags, (
django/views/decorators/debug.py: assert isinstance(request,
HttpRequest), (
}}}
The work to finish this off is to decide which ones remaining are worth
changing given comments above from Tim and Chris. I suspect not many. The
last one in the list could be; it's potentially user-facing and already
has a nice exception message, so we can just change to `TypeError`. The
ones in contrib.auth.hashers look like sanity checks we don't need to
touch.
--
Ticket URL: <https://code.djangoproject.com/ticket/32508#comment:23>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.05108f06156d4ae68eb1f0b6ec4dfd4e%40djangoproject.com.