[New-bugs-announce] [issue32163] getattr() returns None even when default is given
darkdragon-001
report at bugs.python.org
Tue Nov 28 21:18:28 EST 2017
New submission from darkdragon-001 <darkdragon-001 at web.de>:
# fail.py
def main():
patch = './a'
f = open(patch, 'r')
a = getattr(f,'encoding','ascii')
print(str(a))
if __name__ == "__main__":
main()
---
$ touch a
$ python fail.py
It still prints out 'None' instead of 'ascii'. This issue is fixed in python3.
----------
messages: 307197
nosy: darkdragon-001
priority: normal
severity: normal
status: open
title: getattr() returns None even when default is given
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32163>
_______________________________________
More information about the New-bugs-announce
mailing list