Bug #90933
action commentaire, avec un templatetag for sur un LazyField qui vaut None (TypeError: 'NoneType' object is not iterable)
Start date:
22 May 2024
Due date:
% Done:
0%
Estimated time:
Patch proposed:
No
Planning:
No
Description
https://sentry.entrouvert.org/entrouvert/publik/issues/126447/
TypeError: 'NoneType' object is not iterable (19 additional frame(s) were not displayed) ... File "django/template/base.py", line 162, in _render return self.nodelist.render(context) File "django/template/base.py", line 938, in render bit = node.render_annotated(context) File "django/template/base.py", line 905, in render_annotated return self.render(context) File "django/template/defaulttags.py", line 182, in render for i, item in enumerate(values): File "wcs/variables.py", line 1404, in __iter__ return iter(self.get_value())
Associated revisions
History
Updated by Lauréline Guérin about 1 year ago
- Subject changed from actio commentaire, avec un templatetag for sur un LazyField qui vaut None (TypeError: 'NoneType' object is not iterable) to action commentaire, avec un templatetag for sur un LazyField qui vaut None (TypeError: 'NoneType' object is not iterable)
Updated by Frédéric Péters about 1 year ago
- Assignee set to Frédéric Péters
<p>{% for service in form_var_software %}{{ service.code }}{% endfor %}</p>
le crash est curieux, je n'arrive pas à capter le contexte précis, sur une liste vide, on ne devrait pas aller jusque là,
with context.push(): values = self.sequence.resolve(context, ignore_failures=True) if values is None: values = [] if not hasattr(values, '__len__'): values = list(values) len_values = len(values) if len_values < 1: return self.nodelist_empty.render(context)
il y a même déjà un test pour vérifier que ça passe :
# test iterating on None value tmpl = Template('a{% for x in form_var_plop3 %}{{x}}{% endfor %}b') assert tmpl.render(context) == 'ab'
Updated by Robot Gitea about 1 year ago
- Status changed from Nouveau to En cours
Frédéric Péters (fpeters) a ouvert une pull request sur Gitea concernant cette demande :
- URL : https://git.entrouvert.org/entrouvert/wcs/pulls/1520
- Titre : WIP: misc: do not iter on empty items (#90933)
- Modifications : https://git.entrouvert.org/entrouvert/wcs/pulls/1520/files
Updated by Robot Gitea about 1 year ago
- Status changed from Solution proposée to Solution validée
Lauréline Guérin (lguerin) a approuvé une pull request sur Gitea concernant cette demande :
Updated by Robot Gitea about 1 year ago
- Status changed from Solution validée to Résolu (à déployer)
Frédéric Péters (fpeters) a mergé une pull request sur Gitea concernant cette demande :
- URL : https://git.entrouvert.org/entrouvert/wcs/pulls/1520
- Titre : misc: do not iter on empty items (#90933)
- Modifications : https://git.entrouvert.org/entrouvert/wcs/pulls/1520/files
Updated by Transition automatique about 1 year ago
- Status changed from Résolu (à déployer) to Solution déployée
misc: do not iter on empty items (#90933)