[New-bugs-announce] [issue28844] Pickling units

Adam report at bugs.python.org
Wed Nov 30 15:25:08 EST 2016


New submission from Adam:

See below code to show you can't round-trip units through pickle:

Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit AMD64)]
import units
u = units.unit('myUnit')
x = u(3.0)
import pickle
f = open('C:/temp/what.pkl', 'wb')
pickle.dump(x, f)
f.close()
f = open('C:/temp/what.pkl', 'rb')
y = pickle.load(f)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-f17cfc395901> in <module>()
----> 1 y = pickle.load(f)

TypeError: __new__() missing 2 required positional arguments: 'num' and 'unit'

----------
messages: 282099
nosy: abz64
priority: normal
severity: normal
status: open
title: Pickling units
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28844>
_______________________________________


More information about the New-bugs-announce mailing list