Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
danphenderson authored and mxschmitt committed Mar 5, 2024
1 parent 976f04f commit 0e65fb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions playwright/_impl/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,20 +334,22 @@ def _send_message_to_server(
"line": frames[0]["line"],
"column": frames[0]["column"],
}
if len(frames) > 0
if frames
else None
)
metadata = {
"wallTime": int(datetime.datetime.now().timestamp() * 1000),
"apiName": stack_trace_information["apiName"],
"internal": not stack_trace_information["apiName"],
}
if location:
metadata["location"] = location # type: ignore
message = {
"id": id,
"guid": object._guid,
"method": method,
"params": self._replace_channels_with_guids(params),
"metadata": {
"wallTime": int(datetime.datetime.now().timestamp() * 1000),
"apiName": stack_trace_information["apiName"],
"location": location,
"internal": not stack_trace_information["apiName"],
},
"metadata": metadata,
}
if self._tracing_count > 0 and frames and object._guid != "localUtils":
self.local_utils.add_stack_to_tracing_no_reply(id, frames)
Expand Down
4 changes: 2 additions & 2 deletions playwright/_impl/_js_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def serialize_value(
if math.isnan(value):
return dict(v="NaN")
if isinstance(value, datetime):
return dict(d=value.isoformat())
return dict(d=datetime.strftime(value, "%Y-%m-%dT%H:%M:%S.%fZ"))
if isinstance(value, bool):
return {"b": value}
if isinstance(value, (int, float)):
Expand Down Expand Up @@ -205,7 +205,7 @@ def parse_value(value: Any, refs: Optional[Dict[int, Any]] = None) -> Any:
return a

if "d" in value:
return datetime.fromisoformat(value["d"][:-1])
return datetime.strptime(value["d"], "%Y-%m-%dT%H:%M:%S.%fZ")

if "o" in value:
o: Dict = {}
Expand Down

0 comments on commit 0e65fb7

Please sign in to comment.