From e3c12f7116d749e965b0ab390fdac4a98524d9fa Mon Sep 17 00:00:00 2001 From: Lutz Roeder Date: Thu, 18 Jul 2024 20:45:42 -0700 Subject: [PATCH] Update Python test file (#901) --- source/python.js | 8 +++++--- test/models.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/python.js b/source/python.js index a2e91e1936..77b766804e 100644 --- a/source/python.js +++ b/source/python.js @@ -3680,9 +3680,11 @@ python.Execution = class { } return undefined; }); - this.registerFunction('dill._dill._create_type', (/* typeobj */) => { - // return execution.invoke(typeobj, Array.from(arguments).slice(1)); - throw new python.Error("'dill._dill._create_type' not implemented."); + this.registerFunction('dill._dill._create_type', (typeobj, ...args) => { + const [name, bases, dict] = args; + const type = class extends bases[0] {}; + const identifier = dict.__module__ ? `${dict.__module__}.${name}` : name; + return self.registerType(identifier, Object.assign(type, dict)); }); this.registerFunction('dill._dill._eval_repr'); this.registerFunction('dill._dill._get_attr', (self, name) => { diff --git a/test/models.json b/test/models.json index e5d793097b..d1b5622869 100644 --- a/test/models.json +++ b/test/models.json @@ -4757,7 +4757,7 @@ "target": "dill_custom_class.pkl", "source": "https://github.com/lutzroeder/netron/files/13035743/dill_custom_class.pkl.zip[dill_custom_class.pkl]", "format": "Pickle", - "error": "'dill._dill._create_type' not implemented.\nUnknown type name '__builtin__.__main__'.", + "error": "Unknown type name '__builtin__.__main__'.\nUnsupported Pickle type '__main__.CustomClass'.", "link": "https://github.com/lutzroeder/netron/issues/901" }, {