Edward O added the comment:
Here is a workaround for subclasses (2&3-compatible):
--- start code ---
class MyDate(datetime):
@classmethod
def fromDT(cls, d):
""" :type d: datetime """
return cls(d.year, d.month, d.day, d.hour,
Changes by Edward O :
--
nosy: +eddygeek
___
Python tracker
<http://bugs.python.org/issue20371>
___
___
Python-bugs-list mailing list
Unsubscribe:
Edward O added the comment:
The arguments for fixing:
* int subclasses overriding str is a very common usecase for enums (so much so
that it was added to stdlib in 3.4).
* json supporting a standard type of a subsequent python version, though not
mandatory, would be beneficial to Py2/Py3
Changes by Edward O :
--
nosy: +BreamoreBoy
___
Python tracker
<http://bugs.python.org/issue22294>
___
___
Python-bugs-list mailing list
Unsubscribe:
Changes by Edward O :
--
nosy: +eddygeek
___
Python tracker
<http://bugs.python.org/issue7434>
___
___
Python-bugs-list mailing list
Unsubscribe:
Changes by Edward O :
--
title: json encoding broken for -> 2.7 json encoding broken for enums
___
Python tracker
<http://bugs.python.org/issue22297>
___
___
Py
New submission from Edward O:
_make_iterencode in python2.7/json/encoder.py encodes custom enum types
incorrectly (the label will be printed without '"') because of these lines
(line 320 in 2.7.6):
elif isinstance(value, (int, long)):
yield buf + str(value
Changes by Edward O :
--
nosy: +benjamin.peterson
___
Python tracker
<http://bugs.python.org/issue22294>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Edward O:
This is a patch for issues similar to #16573
With this patch, the following new tests are now unchanged:
r = dict(zip(s, range(len(s))), **d)
r = len(filter(attrgetter('t'), self.a))
r = min(map(methodcaller('f'), self.a))
max(map(node.id,
Edward O added the comment:
The code works when using encoding='bytes'. Thanks Tim for the suggestion.
So this is not a bug, but is there any sense in having encoding='ASCII' by
default in pickle ?
--
___
Python tracker
<
10 matches
Mail list logo