Message310105
Embedded Python interpreters, such as Boost.Python, do not have sys.argv available. (sys itself works fine.) This causes the interpreter to crash with the following exception when you try to access argv:
AttributeError: 'module' object has no attribute 'argv'
I'm not sure how closely related this is to #15577 or PEP 432. A simple workaround is to manually assign a list with an empty string to argv, as suggested by https://github.com/google/oauth2client/issues/642. However, the documentation for the sys module makes no mention of this special case for argv, and the line at the top that says "It is always available" can easily be interpreted to mean that *all* of sys's attributes will always be available. I suggest adding the following to the documentation for sys.argv:
========
Since `argv` contains the list of **command line** arguments passed to the Python interpreter, `argv` is not available within embedded interpreters, and scripts that run in embedded environments will raise an `AttributeError` when they attempt to access `argv`. As a workaround, assign a list with an empty string manually:
```
import sys
if not hasattr(sys, 'argv'):
sys.argv = ['']
``` |
|
Date |
User |
Action |
Args |
2018-01-16 19:46:28 | pgacv2 | set | recipients:
+ pgacv2, docs@python |
2018-01-16 19:46:28 | pgacv2 | set | messageid: <1516131988.33.0.467229070634.issue32573@psf.upfronthosting.co.za> |
2018-01-16 19:46:28 | pgacv2 | link | issue32573 messages |
2018-01-16 19:46:28 | pgacv2 | create | |
|