import web fails in embedded Interpreter #87

Closed
goldcode opened this Issue Jul 15, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@goldcode

Since the embedded python interpreter perhaps has no arguments passed to it, the code fails. On commenting out the _is_dev_mode function internals, i can move on...

File "Tests.py", line 13, in
import web

File "C:\Python27\lib\site-packages\web__init__.py", line 14, in
import utils, db, net, wsgi, http, webapi, httpserver, debugerror

File "C:\Python27\lib\site-packages\web\wsgi.py", line 66, in
web.config.setdefault('debug', _is_dev_mode())

File "C:\Python27\lib\site-packages\web\wsgi.py", line 60, in _is_dev_mode
or 'fcgi' in sys.argv or 'fastcgi' in sys.argv \

AttributeError: 'module' object has no attribute 'argv'

@anandology

This comment has been minimized.

Show comment Hide comment
@anandology

anandology Jul 16, 2011

Member

No sys.argv? something wrong with your python installation?

Member

anandology commented Jul 16, 2011

No sys.argv? something wrong with your python installation?

@goldcode

This comment has been minimized.

Show comment Hide comment
@goldcode

goldcode Jul 16, 2011

Nothing wrong with the installation. The python interpreter library is embedded in a c++ based application. No python.exe but a python27.lib is used and the c api functions are called to instantiate and use the interpreter. This seems to be a common issue for libraries which are used with the embedded interpreter.

e.g.
https://bugs.launchpad.net/apport/+bug/119437
http://bugs.python.org/issue839151

Of course i can make sure the attribute exists using PySys_SetArgvEx and then it runs, however i do not know if another library i use/will use has other side effects due to these command line parameters.

How about an interface which accepts name-value pairs as configuration info rather than from the command line?

For the embedded case i could make a patch for all usages of sys.argv where argv does not exist. Currently the following files are affected.

c:\Python27\Lib\site-packages\web\application.py
c:\Python27\Lib\site-packages\web\debugerror.py
c:\Python27\Lib\site-packages\web\template.py
c:\Python27\Lib\site-packages\web\test.py
c:\Python27\Lib\site-packages\web\wsgi.py

Nothing wrong with the installation. The python interpreter library is embedded in a c++ based application. No python.exe but a python27.lib is used and the c api functions are called to instantiate and use the interpreter. This seems to be a common issue for libraries which are used with the embedded interpreter.

e.g.
https://bugs.launchpad.net/apport/+bug/119437
http://bugs.python.org/issue839151

Of course i can make sure the attribute exists using PySys_SetArgvEx and then it runs, however i do not know if another library i use/will use has other side effects due to these command line parameters.

How about an interface which accepts name-value pairs as configuration info rather than from the command line?

For the embedded case i could make a patch for all usages of sys.argv where argv does not exist. Currently the following files are affected.

c:\Python27\Lib\site-packages\web\application.py
c:\Python27\Lib\site-packages\web\debugerror.py
c:\Python27\Lib\site-packages\web\template.py
c:\Python27\Lib\site-packages\web\test.py
c:\Python27\Lib\site-packages\web\wsgi.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment