Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions storage/google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,7 @@ def metadata(self, value):
:type value: dict
:param value: (Optional) The blob metadata to set.
"""
value = {k: str(v) for k, v in value.items()}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @HemangChothani!

Could you also add this to bucket labels given the similarity?

self._patch_property("metadata", value)

@property
Expand Down
10 changes: 10 additions & 0 deletions storage/tests/unit/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2913,6 +2913,16 @@ def test_metadata_setter(self):
blob.metadata = METADATA
self.assertEqual(blob.metadata, METADATA)

def test_metadata_setter_w_nan(self):
BLOB_NAME = "blob-name"
METADATA = {"foo": float("nan")}
bucket = _Bucket()
blob = self._make_one(BLOB_NAME, bucket=bucket)
self.assertIsNone(blob.metadata)
blob.metadata = METADATA
value = blob.metadata["foo"]
self.assertIsInstance(value, str)

def test_metageneration(self):
BUCKET = object()
METAGENERATION = 42
Expand Down