Skip to content

Commit

Permalink
Clean up deprecated module removed in python 3.13 (#9004)
Browse files Browse the repository at this point in the history
* Remove deprecated module removed in python 3.13

* Update validate to use helper function

* Add translation wrapper to error message
  • Loading branch information
1337joe authored Feb 2, 2025
1 parent 56bfbfb commit 1912e75
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/backend/InvenTree/part/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""DRF data serializers for Part app."""

import imghdr
import io
import os
from decimal import Decimal
Expand Down Expand Up @@ -298,9 +297,9 @@ class Meta:

def validate_image(self, value):
"""Check that file is an image."""
validate = imghdr.what(value)
validate = InvenTree.helpers.TestIfImage(value)
if not validate:
raise serializers.ValidationError('File is not an image')
raise serializers.ValidationError(_('File is not an image'))
return value

image = InvenTree.serializers.InvenTreeAttachmentSerializerField(required=True)
Expand Down

0 comments on commit 1912e75

Please sign in to comment.