Skip to content

Commit 30a514e

Browse files
ffissoreedenhill
authored andcommitted
Use str(Schema) rather than Schema.to_json to prevent fastavro from raising exception TypeError: unhashable type: 'mappingproxy'
Fixes confluentinc#1156
1 parent 21254fa commit 30a514e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/confluent_kafka/avro/serializer/message_serializer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# derived from https://github.com/verisign/python-confluent-schemaregistry.git
2121
#
2222
import io
23+
import json
2324
import logging
2425
import struct
2526
import sys
@@ -79,7 +80,7 @@ def __init__(self, registry_client, reader_key_schema=None, reader_value_schema=
7980
# Encoder support
8081
def _get_encoder_func(self, writer_schema):
8182
if HAS_FAST:
82-
schema = writer_schema.to_json()
83+
schema = json.loads(str(writer_schema))
8384
parsed_schema = parse_schema(schema)
8485
return lambda record, fp: schemaless_writer(fp, parsed_schema, record)
8586
writer = avro.io.DatumWriter(writer_schema)
@@ -175,8 +176,8 @@ def _get_decoder_func(self, schema_id, payload, is_key=False):
175176
if HAS_FAST:
176177
# try to use fast avro
177178
try:
178-
fast_avro_writer_schema = parse_schema(writer_schema_obj.to_json())
179-
fast_avro_reader_schema = parse_schema(reader_schema_obj.to_json())
179+
fast_avro_writer_schema = parse_schema(json.loads(str(writer_schema_obj)))
180+
fast_avro_reader_schema = parse_schema(json.loads(str(reader_schema_obj)))
180181
schemaless_reader(payload, fast_avro_writer_schema)
181182

182183
# If we reach this point, this means we have fastavro and it can

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy