New submission from steven Michalske <smichal...@gmail.com>:

With the source

```
import cgitb
import sys

try:
    f = open('non_exitant_file_path.foo')
except Exception as e:
    cgitb.text(sys.exc_info())
```

we get the output

```
Traceback (most recent call last):
  File "foo.py", line 22, in <module>
    f = open('non_exitant_file_path.foo')
FileNotFoundError: [Errno 2] No such file or directory: 
'non_exitant_file_path.foo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo.py", line 24, in <module>
    cgitb.text(sys.exc_info())
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/cgitb.py", 
line 245, in text
    value = pydoc.text.repr(getattr(evalue, name))
AttributeError: characters_written
```

In bug #30554 it was brought up that there are attributes designed as invariant 
os some other as designed behavior.  Unfortunately it was closed "as designed" 

So this means that cgitb has a bug when text formatting a sys_exc traceback of 
an OSError.

This is hidden in the by the hook with this code form cgitb.py
by falling back to the standard formatter...

line 277
```
        try:
            doc = formatter(info, self.context)
        except:                         # just in case something goes wrong
            doc = ''.join(traceback.format_exception(*info))
            plain = True
```

----------
messages: 310702
nosy: hardkrash
priority: normal
severity: normal
status: open
title: cgitb file to print OSError exceptions
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32669>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to