my.core.serialize: orjson with additional default and _serialize hook (#140)

basic orjson serialize, json.dumps fallback

Lots of surrounding changes from this discussion:
0593c69056
This commit is contained in:
Sean Breckenridge 2021-03-19 17:48:03 -07:00 committed by GitHub
parent 02a9fb5e8f
commit eb26cf8633
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 224 additions and 24 deletions

View file

@ -145,15 +145,9 @@ def extract_error_datetime(e: Exception) -> Optional[datetime]:
import traceback
from .common import Json
def error_to_json(e: Exception, *, dt_col: str='dt', tz=None) -> Json:
edt = extract_error_datetime(e)
if edt is not None and edt.tzinfo is None and tz is not None:
edt = edt.replace(tzinfo=tz)
def error_to_json(e: Exception) -> Json:
estr = ''.join(traceback.format_exception(Exception, e, e.__traceback__))
return {
'error': estr,
dt_col : edt,
}
return {'error': estr}
def test_datetime_errors() -> None: