Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jupyter_server/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mimetypes
import os
import re
import sqlite3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a guard in case if Python build does no include sqlite3? There is one here:

try:
import sqlite3
except ImportError:
# fallback on pysqlite2 if Python was build without sqlite
from pysqlite2 import dbapi2 as sqlite3 # type:ignore[no-redef]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krassowski

Good catch, I also saw that these attributes were only introduced in python 3.11, so I've made this check a bit more robust, with a string based comparison as fallback

import types
import warnings
from http.client import responses
Expand Down Expand Up @@ -765,6 +766,12 @@ def write_error(self, status_code: int, **kwargs: Any) -> None:
if isinstance(e, HTTPError):
reply["message"] = e.log_message or message
reply["reason"] = e.reason
elif (
isinstance(e, sqlite3.OperationalError)
and e.sqlite_errorcode == sqlite3.SQLITE_FULL
):
reply["message"] = "Disk is full"
reply["reason"] = e.sqlite_errorname
else:
reply["message"] = "Unhandled error"
reply["reason"] = None
Expand Down