Issue839151
Created on 2003年11月10日 10:56 by vimboss, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files |
| File name |
Uploaded |
Description |
Edit |
|
diff
|
vimboss,
2003年11月10日 10:56
|
patch for warnings.py |
| Messages (6) |
|
msg18953 - (view) |
Author: Bram Moolenaar (vimboss) |
Date: 2003年11月10日 10:56 |
When using Python as an extension to another program,
giving a warning message attempts to access sys.argv
while it doesn't exist.
The problem can be reproduced with Vim when compiled
with Python 2.3. Use these two commands:
:py import sys
:py print sys.maxint + 1
The problem is caused by the warnings module. In line
53 it accesses sys.argv[0], but for an embedded
interpreter this doesn't exist.
The suggested fix does an explicit test for the
existence of sys.argv. That seems to be the cleanest
solution to me.
This problem also existed in Python 2.2. I didn't try
other versions.
|
|
msg18954 - (view) |
Author: Neal Norwitz (nnorwitz) * (Python committer) |
Date: 2003年11月10日 15:02 |
Logged In: YES
user_id=33168
Just to provide a reference, 839200 was a duplicate of this
report. I closed 839200.
|
|
msg18955 - (view) |
Author: Nobody/Anonymous (nobody) |
Date: 2003年11月19日 05:22 |
Logged In: NO
Much simplier test:
>>> import sys
>>> del sys.argv
>>> sys.maxint+1
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "D:\development\python22\lib\warnings.py", line 38,
in warn
filename = sys.argv[0]
AttributeError: 'module' object has no attribute 'argv'
|
|
msg18956 - (view) |
Author: Nobody/Anonymous (nobody) |
Date: 2003年11月19日 05:23 |
Logged In: NO
Much simplier test:
>>> import sys
>>> del sys.argv
>>> sys.maxint+1
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "D:\development\python22\lib\warnings.py", line 38,
in warn
filename = sys.argv[0]
AttributeError: 'module' object has no attribute 'argv'
|
|
msg18957 - (view) |
Author: Georg Brandl (georg.brandl) * (Python committer) |
Date: 2005年06月26日 22:55 |
Logged In: YES
user_id=1188172
Thanks for the report; this is fixed as of Lib/warnings.py
r1.27, r1.24.2.2.
|
|
msg18958 - (view) |
Author: Nishkar Grover (ngrover) |
Date: 2007年08月22日 01:29 |
In addition to catching AttributeError in case sys.argv doesn't exist, this should also catch IndexError and TypeError in case sys.argv is an empty list or it is not even a list at all.
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2022年04月11日 14:56:01 | admin | set | github: 39528 |
| 2003年11月10日 10:56:09 | vimboss | create |