#32986: Possible dead or incorrect code in Lexer.create_token() related to
TRANSLATOR_COMMENT_MARK
------------------------------------------------+------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Template system | Version: dev
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 |
------------------------------------------------+------------------------
While working on [https://github.com/django/django/pull/14739 this PR] for
ticket #32919, I noticed that `Lexer.create_token()` has a branch of code
that looks like it might be wrong or not needed.
Specifically,
[https://github.com/django/django/blob/4f3acf957918843b4c40ff2edfb929bcfaa3730e/django/template/base.py#L391
this line] seems always to be true. It's true both when
`TRANSLATOR_COMMENT_MARK` is found and not found. It's only false when
`token_string` starts with `TRANSLATOR_COMMENT_MARK` since `str.find()` is
used (as it returns the index). However, when I tried modifying the code
in [https://github.com/django/django/pull/14742 this test PR] to raise an
exception in the false code path, the test suite still passed. So it's not
clear to me if the `str.find()` call is needed, or if it's just incorrect.
--
Ticket URL: <https://code.djangoproject.com/ticket/32986>
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/052.44aacf1ff555022cc9a10a423df94f18%40djangoproject.com.