Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dont use literal eval (why was this even there!?) for logging emit #350

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
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
6 changes: 2 additions & 4 deletions scrapli/logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""scrapli.logging"""

from ast import literal_eval

# slightly irritating renaming to prevent a cyclic lookup in griffe for mkdocstrings
from logging import FileHandler as FileHandler_
from logging import Formatter as Formatter_
Expand Down Expand Up @@ -223,13 +221,13 @@ def emit(self, record: LogRecord_) -> None:
# no message in the buffer, set the current record to the _record_buf
self._record_buf = record
# get the payload of the message after "read: " and re-convert it to bytes
self._record_msg_buf = literal_eval(record.msg[self._read_msg_prefix_len :]) # noqa
self._record_msg_buf = record.msg[self._read_msg_prefix_len :].encode()
return

# if we get here we know we are getting subsequent read messages we want to buffer -- the
# log record data will all be the same, its just the payload that will be new, so add that
# current payload to the _record_msg_buf buffer
self._record_msg_buf += literal_eval(record.msg[self._read_msg_prefix_len :]) # noqa
self._record_msg_buf += record.msg[self._read_msg_prefix_len :].encode()


def get_instance_logger(
Expand Down
Loading