Skip to content

Commit 693b229

Browse files
author
Paul Sokolovsky
committed
pickle: Very rough implementation of pickle loads from imported modules.
Allows to implement minimal pickling for datetime objects.
1 parent 96a6033 commit 693b229

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pickle/pickle.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ def load(f):
1212

1313
def loads(s):
1414
d = {}
15+
if "(" in s:
16+
qualname = s.split("(", 1)[0]
17+
if "." in qualname:
18+
pkg = qualname.rsplit(".", 1)[0]
19+
mod = __import__(pkg)
20+
d[pkg] = mod
1521
exec("v=" + s, d)
1622
return d["v"]

0 commit comments

Comments
 (0)