Skip to content

Conversation

furkanonder
Copy link
Contributor

@furkanonder furkanonder commented Sep 10, 2025

@furkanonder furkanonder requested a review from picnixz September 10, 2025 19:22
@furkanonder furkanonder added type-feature A feature request or enhancement extension-modules C modules in the Modules dir labels Sep 10, 2025
self.deserializer = deserializer

@staticmethod
def _validate_serialized_value(serialized_value, original_value):
Copy link
Member

@picnixz picnixz Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation is also at the level of the C extension (in dbmmodule.c) so you should also change the message out there.

else:
invalid_type = type(serialized_value).__name__
msg = (f"Serializer returned {invalid_type} for value "
f"{original_value!r} But database values must be "
Copy link
Contributor

@aisk aisk Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, 'But' should be lowercase unless it follows a period:

Suggested change
f"{original_value!r} But database values must be "
f"{original_value!r}, but database values must be "

Adding a period before it is another option.

@encukou
Copy link
Member

encukou commented Oct 17, 2025

I've sent some suggestions as a PR to your branch: furkanonder#3

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is the best solution of the original issue. Making error messages in the underlying database more specific would help too.

Comment on lines +117 to +119
msg = (f"Serializer returned {invalid_type} for value "
f"{original_value!r} But database values must be "
f"bytes or str, not {invalid_type}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid_type is repeated twice. This is unnecessary.

The repr of original_value can be very large, it should not be included in the error message. Error most likely does not depend on the original value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants