[Python-Dev] Add a frozendict builtin type (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Thu Mar 1 10:11:03 CET 2012
- Previous message: [Python-Dev] Add a frozendict builtin type
- Next message: [Python-Dev] Add a frozendict builtin type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Problem: if you implement a frozendict type inheriting from dict in Python, it is still possible to call dict methods (e.g. dict.setitem()). To fix this issue, pysandbox removes all dict methods modifying the dict: setitem, delitem, pop, etc. This is a problem because untrusted code cannot use these methods on valid dict created in the sandbox.
You can redefine dict.setitem.
Ah? It doesn't work here.
dict.setitem=lambda key, value: None Traceback (most recent call last): File "", line 1, in TypeError: can't set attributes of built-in/extension type 'dict'
Victor
- Previous message: [Python-Dev] Add a frozendict builtin type
- Next message: [Python-Dev] Add a frozendict builtin type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]