[issue24590] Customized attribute access causes infinite loop

2015-07-08 Thread Zorceta

New submission from Zorceta:

Code and result:

```
 class A:
def __init__(self):
self.data = {'a': 1, 'b': 2, 'c': 3}
def __getattr__(self, name):
print('in __getattr__, getting %s' % name)
if name in self.data:
return self.data[name]
else:
raise AttributeError
def __setattr__(self, name, value):
print('in __setattr__, setting %s to %s' % (name, value))
if name in self.data:
self.data[name] = value
else:
self.__class__.__setattr__(self, name, value)


 a = A()
in __setattr__, setting data to {'a': 1, 'b': 2, 'c': 3}
in __getattr__, getting data
in __getattr__, getting data
in __getattr__, getting data
..
```

From above you can see it stuck on

 if name in self.data:

in `__setattr__`.

But, the result indicates that `__setattr__` uses `__getattr__` to read the 
`data` attribute, which is against docs:

Note that if the attribute is found through the normal mechanism, 
__getattr__() is not called.

If it acts as described, `data` should be read through the normal mechanism, 
not through `__getattr__`.

--
messages: 246453
nosy: zorceta
priority: normal
severity: normal
status: open
title: Customized attribute access causes infinite loop
type: behavior
versions: Python 3.4

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



[issue24589] Wrong behavior for list of lists

2015-07-08 Thread Zorceta

Zorceta added the comment:

FYI:

 ll = [[]]*10
 [id(l) for l in ll]
[67940296, 67940296, 67940296, 67940296, 67940296, 67940296, 67940296, 
67940296, 67940296, 67940296]

--
nosy: +zorceta

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



[issue24590] Unappropriate issue

2015-07-08 Thread Zorceta

Changes by Zorceta zorc...@gmail.com:


--
title: Customized attribute access causes infinite loop - Unappropriate issue

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



[issue24590] Customized attribute access causes infinite loop

2015-07-08 Thread Zorceta

Changes by Zorceta zorc...@gmail.com:


--
status: open - closed

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



[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-24 Thread Zorceta

Zorceta added the comment:

 When provided object is not from a file

should be

'When `inspect` can't find the source file of provided object'.

My mistake.

--

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



[issue24491] inspect.getsource can't get source code if provided function isn't from a file

2015-06-23 Thread Zorceta

New submission from Zorceta:

Both python.exe and IDLE can't. IPython is able to, as it inserts REPL input 
into linecache.

--
messages: 245694
nosy: zorceta
priority: normal
severity: normal
status: open
title: inspect.getsource can't get source code if provided function isn't from 
a file
type: behavior
versions: Python 3.4

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



[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Zorceta

Changes by Zorceta zorc...@gmail.com:


--
nosy:  -docs@python

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



[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Zorceta

Changes by Zorceta zorc...@gmail.com:


--
components: +IDLE, Interpreter Core -Documentation

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



[issue12920] inspect.getsource only works for objects loaded from files, not interactive session

2015-06-23 Thread Zorceta

Zorceta added the comment:

When provided object is not from a file, like input in interactive shell, 
`inspect` internals will check for it in `linecache`, which official Python 
shell and IDLE won't put interactive shell input into, yet. This can be simply 
solved.

Whether interactive shell input can be put into `linecache` may be a problem, 
but it'll make life easier, as interactive shell saves time from edit-save-run 
'loop'.

btw, I changed the title, since I don't think, what original author thought 
need to be documented, is absolutely right.

--
title: Document that inspect.getsource only works for objects loaded from 
files, not interactive session - inspect.getsource only works for objects 
loaded from files, not interactive session

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