Re: [PyInstaller] Suggestion: cgitb in loader for debug

2016-05-30 Thread Hartmut Goebel
Am 30.05.2016 um 17:40 schrieb David Cortesi:
> import cgitb
> cgitb.enable(format='text')

This sound like a good idea. it should at least go into "if things go
wrong".

Regarding adding it to an optional startup-script, I'm two-fold, since
it produces *a lot* of output as my simple test showed (see below). For
me this is more confusing than the original traceback. And given the
obvious lack of knowledge of some users on how to read a traceback, I'm
unsure if this really helps.
OTOH we could spot curious import errors more easily since the source
would be shown directly.

maybe we just try it out :-)

$ python /tmp/x.py

Python 2.7.9: /usr/bin/python

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /tmp/x.py in ()
3
4 def f(i):
5 x = i / 0
6
7 f(42)
f = 

 /tmp/x.py in f(i=42)
3
4 def f(i):
5 x = i / 0
6
7 f(42)
x undefined
i = 42
: integer division or modulo by zero
__class__ = 
__delattr__ =  
   

__dict__ =
{}
__doc__ = 'Second argument to a division or modulo operation was
zero.'  
__format__ =  
__getattribute__ =  
 

__getitem__ =  
   

__getslice__ =  
 

__hash__ = 
__init__ = 
__new__ =
__reduce__ =  
__reduce_ex__ =  


__repr__ = 
__setattr__ =  
   

__setstate__ =  
  

__sizeof__ =  
__str__ = 
__subclasshook__ = 
__unicode__ = 
args = ('integer division or modulo by zero',)
message = 'integer division or modulo by zero'

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "/tmp/x.py", line 7, in 
f(42)
  File "/tmp/x.py", line 5, in f
x = i / 0
ZeroDivisionError: integer division or modulo by zero


-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog:
http://www.goebel-consult.de/blog/liberario-als-alternative-zum-db-navigator-und-zu-offi

Kolumne:
http://www.cissp-gefluester.de/2012-09-steht-ein-manta-fahrer-vor-der-uni

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyinstaller+unsubscr...@googlegroups.com.
To post to this group, send email to pyinstaller@googlegroups.com.
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature


[PyInstaller] Suggestion: cgitb in loader for debug

2016-05-30 Thread David Cortesi
I'm reading the writeup on the cgitb (extended traceback) module on the
PMOTW blog:

https://pymotw.com/3/cgitb/

To get a much longer & more informative traceback of an error, it is only
necessary to use

import cgitb
cgitb.enable(format='text')

at the start of execution. It occurs to me that the PyInstaller bootloader
could do this prior to invoking the main script. Then if the script fails,
there will be much more than the standard traceback, without any code
changes needed in the bundled script.

Obviously this should not be done normally, but it might be done when the
--debug flag is used. This would mean PyInstaller would have to make sure
to bundle the cgitb module if --debug is given, and the bootloader could do
the import and enable before starting the main script.

Does this sound like a good idea? If not, at least we should mention cgitb
in the "when things go wrong" section?

Dave Cortesi

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyinstaller+unsubscr...@googlegroups.com.
To post to this group, send email to pyinstaller@googlegroups.com.
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.