[ python-Bugs-839151 ] attempt to access sys.argv when it doesn't
exist
SourceForge.net
noreply at sourceforge.net
Wed Nov 19 00:23:45 EST 2003
Bugs item #839151, was opened at 2003-11-10 02:56
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=839151&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Bram Moolenaar (vimboss)
Assigned to: Nobody/Anonymous (nobody)
Summary: attempt to access sys.argv when it doesn't exist
Initial Comment:
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.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2003-11-18 21:23
Message:
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'
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2003-11-18 21:22
Message:
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'
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2003-11-10 07:02
Message:
Logged In: YES
user_id=33168
Just to provide a reference, 839200 was a duplicate of this
report. I closed 839200.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=839151&group_id=5470
More information about the Python-bugs-list
mailing list