[issue3635] pickle.dumps cannot save instance of dict-derived class that overrides __getattribute__

2011-12-05 Thread Alexandre Vassalotti

Alexandre Vassalotti alexan...@peadrop.com added the comment:

I don't think it is a bug.

The posted code completely breaks the expected behavior of __getattribute__. 
With a such implementation, there is nothing we can do with this object as we 
cannot introspect it.

Use the following if you really need this kind of behaviour:

class E(dict):
def __getattribute__(self,name):
try:
return self[name]
except KeyError:
return dict.__getattribute__(self, name)

--
resolution:  - works for me
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3635
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3635] pickle.dumps cannot save instance of dict-derived class that overrides __getattribute__

2011-06-26 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Should this be closed for the same reason #1730480 was?
If not, would this effectively be a feature request and have to wait for a new 
version (3.3)?

--
nosy: +alexandre.vassalotti, pitrou, terry.reedy
versions: +Python 2.7, Python 3.2 -Python 2.6, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3635
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3635] pickle.dumps cannot save instance of dict-derived class that overrides __getattribute__

2009-05-16 Thread Daniel Diniz

Daniel Diniz aja...@gmail.com added the comment:

Is this related to #1730480?

--
nosy: +ajaksu2
priority:  - normal
stage:  - test needed
versions: +Python 2.6, Python 3.1 -Python 2.5, Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3635
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3635] pickle.dumps cannot save instance of dict-derived class that overrides __getattribute__

2008-08-21 Thread Michael Yang

New submission from Michael Yang [EMAIL PROTECTED]:

# pickle.dumps is not able to process an instance of
# a class that inherits from 'dict' and
# overrides the built-in __getattribute__ method
# but can successfully process one that 
# overrides the__getattr__ method

 class Examp1(dict):
...   def __getattr__(self,name):
... return self[name]
... 
 class Examp2(dict):
...   def __getattribute__(self,name):
... return self[name]
... 
 ex1 = Examp1()
 ex2 = Examp2()
 ex1['aKey'] = (3,4)
 ex2['aKey2'] = (4,5)
 ex1
{'aKey': (3, 4)}
 ex1.aKey
(3, 4)
 ex2
{'aKey2': (4, 5)}
 ex2.aKey2
(4, 5)
 import pickle
 pickle.dumps(ex1)
b'\x80\x03c__main__\nexamp1\nq\x00)\x81q\x01X\x04\x00\x00\x00aKeyq\x02K\x03K\x04\x86q\x03s}q\x04b.'
 pickle.dumps(ex2)
Traceback (most recent call last):
  File stdin, line 1, in module
  File [hidden]/python3/3.0b2/common/lib/python3.0/pickle.py, line
1319, in dumps
Pickler(f, protocol).dump(obj)
  File stdin, line 3, in __getattribute__
KeyError: '__reduce_ex__'

--
components: Extension Modules
messages: 71671
nosy: msyang
severity: normal
status: open
title: pickle.dumps cannot save instance of dict-derived class that overrides 
__getattribute__
type: behavior
versions: Python 2.5, Python 3.0

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3635
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com