Skip to content

Commit

Permalink
Encapsulate timestamp boolean check in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Deckard authored and lafrech committed May 1, 2024
1 parent 6e72beb commit 58fbbcd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/marshmallow/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,6 @@ def _serialize(self, value, attr, obj, **kwargs) -> str | float | None:
return value.strftime(data_format)

def _deserialize(self, value, attr, data, **kwargs) -> dt.datetime:
if value is True or value is False:
raise self.make_error("invalid", input=value, obj_type=self.OBJ_TYPE)
data_format = self.format or self.DEFAULT_FORMAT
func = self.DESERIALIZATION_FUNCS.get(data_format)
try:
Expand Down
2 changes: 2 additions & 0 deletions src/marshmallow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def from_iso_date(value):


def from_timestamp(value: typing.Any) -> dt.datetime:
if value is True or value is False:
raise ValueError("Not a valid POSIX timestamp")
value = float(value)
if value < 0:
raise ValueError("Not a valid POSIX timestamp")
Expand Down

0 comments on commit 58fbbcd

Please sign in to comment.