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 json.dump/dumps() with IPv4Address #9769

Closed
wants to merge 1 commit into from
Closed
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: 5 additions & 1 deletion shared-bindings/ipaddress/IPv4Address.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ static void ipaddress_ipv4address_print(const mp_print_t *print, mp_obj_t self_i
mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ);

const uint8_t *buf = (uint8_t *)buf_info.buf;
mp_printf(print, "%d.%d.%d.%d", buf[0], buf[1], buf[2], buf[3]);
if (kind == PRINT_JSON) {
mp_printf(print, "\"%d.%d.%d.%d\"", buf[0], buf[1], buf[2], buf[3]);
} else {
mp_printf(print, "%d.%d.%d.%d", buf[0], buf[1], buf[2], buf[3]);
}
}

static const mp_rom_map_elem_t ipaddress_ipv4address_locals_dict_table[] = {
Expand Down