From 027e98605cef41eca04aa90a9accd04b66231320 Mon Sep 17 00:00:00 2001 From: Cyprien CAILLOT Date: Wed, 11 Sep 2024 14:10:53 +0200 Subject: [PATCH] Bug: Replace ast.literal_eval with json.loads to avoid crashes on Unreal --- openpype/hosts/unreal/api/plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/unreal/api/plugin.py b/openpype/hosts/unreal/api/plugin.py index 26ef69af864..c2fc9fc47c6 100644 --- a/openpype/hosts/unreal/api/plugin.py +++ b/openpype/hosts/unreal/api/plugin.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -import ast import collections import sys import six +import json from abc import ( ABC, ABCMeta, @@ -110,9 +110,10 @@ def collect_instances(self): for instance in self.collection_shared_data[ "unreal_cached_subsets"].get(self.identifier, []): # Unreal saves metadata as string, so we need to convert it back - instance['creator_attributes'] = ast.literal_eval( + # Not using ast.literal_eval since your can have issues with quotes/formatting + instance['creator_attributes'] = json.loads( instance.get('creator_attributes', '{}')) - instance['publish_attributes'] = ast.literal_eval( + instance['publish_attributes'] = json.loads( instance.get('publish_attributes', '{}')) created_instance = CreatedInstance.from_existing(instance, self) self._add_instance_to_context(created_instance)