2👍
✅
The code expecting a ‘name’ attribute to exist is wrong. The Python documentation says about the ‘name’ attribute:
“””name – If the file object was created using open(), the name of the file. Otherwise, some string that indicates the source of the file object, of the form “<…>”. This is a read-only attribute and may not be present on all file-like objects.”””
In other words, it is not required to be present.
The mod_wsgi.Log object, which is standing in as a file object for sys.stdout and sys.stderr, therefore doesn’t need to have a ‘name’ attribute.
As such, any code which is looking for ‘name’ attribute has to be tolerant of it not existing.
Source:stackexchange.com