New issue 2029: lambdas not is not JSON serializable
https://bitbucket.org/pypy/pypy/issue/2029/lambdas-not-is-not-json-serializable

gjvc:

This code runs fine in CPython 2.7, but not in pypy


```
#!python

#! /usr/bin/env python

import collections
import json


class objdict( collections.defaultdict ):

    def __getattr__( self, key ):
        try:
            return self.__dict__[ key ]
        except KeyError:
            return self.__getitem__( key )

    __setattr__ = lambda self, key, value: self.__setitem__( key, value )

def objtree():
    return objdict(objtree)


obj = objtree()
print json.dumps( obj, indent=4 )
obj.x.y.z = 4
print json.dumps( obj, indent=4 )
obj.x.y = 3
print json.dumps( obj, indent=4 )
obj.x = 2
print json.dumps( obj, indent=4 )
del obj[ 'x' ]
print json.dumps( obj, indent=4 )

```



_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to