diff --git a/debug_toolbar/panels/request.py b/debug_toolbar/panels/request.py index 9e60207fe..b77788637 100644 --- a/debug_toolbar/panels/request.py +++ b/debug_toolbar/panels/request.py @@ -64,5 +64,8 @@ def generate_stats(self, request, response): (k, request.session.get(k)) for k in sorted(request.session.keys()) ] except TypeError: - session_list = [(k, request.session.get(k)) for k in request.session] + session_list = [ + (k, request.session.get(k)) + for k in request.session.keys() # (it's not a dict) + ] self.record_stats({"session": {"list": session_list}}) diff --git a/docs/changes.rst b/docs/changes.rst index 8de32a1d2..581a9fce1 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -13,6 +13,8 @@ Pending * Add translations for Bulgarian and Korean. * Update translations for several languages. * Include new translatable strings for translation. +* Fixed a crash which happened in the fallback case when session keys cannot be + sorted. 4.4.6 (2024-07-10) ------------------ diff --git a/pyproject.toml b/pyproject.toml index 6060a055f..451887d35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,16 +74,14 @@ lint.extend-select = [ "PGH", # pygrep-hooks "PIE", # flake8-pie "RUF100", # Unused noqa directive - "SIM", # flake8-simplify "SLOT", # flake8-slots "UP", # pyupgrade "W", # pycodestyle warnings ] lint.extend-ignore = [ - "B905", # Allow zip() without strict= - "E501", # Ignore line length violations - "SIM108", # Use ternary operator instead of if-else-block - "UP031", # It's not always wrong to use percent-formatting + "B905", # Allow zip() without strict= + "E501", # Ignore line length violations + "UP031", # It's not always wrong to use percent-formatting ] lint.per-file-ignores."*/migrat*/*" = [ "N806", # Allow using PascalCase model names in migrations