[ python-Bugs-839200 ] some error in worning.py

SourceForge.net noreply at sourceforge.net
Mon Nov 10 09:58:45 EST 2003


Bugs item #839200, was opened at 2003-11-10 08:12
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=839200&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Duplicate
Priority: 5
Submitted By: Eugene Minkovskii (emin0)
Assigned to: Nobody/Anonymous (nobody)
Summary: some error in worning.py

Initial Comment:
I'm using the vim editor. In this product there are 
command
:python {expression}
which run {expression} in this expressions MODUL sys 
HAS NOT ATTRIBUTE argv. And when I run
:python print sys.maxint + 1
I take an error. So, I wrote about this to Bram 
Moonlenaar (vim's maintainer) and He thing It's bug of 
python (I think he is right). 

Below, I put my letters to Bram and his answer.

===8<==============Bram Moonlenaar 
wrote:===============

Eugene Minkovskii wrote:

> I see one bug in the vim.
> So I typing in the vim:
> 
> :py import sys
> :py print sys.maxint
> 2147483647
> :py print sys.maxint + 1
> Traceback (most recent call last):
>   File "<string>", line 1, in ?
>   File "C:\Python23\Lib\warnings.py", line 53, in warn
>     filename = sys.argv[0]
> AttributeError: 'module' object has no attribute 'argv'
> :py print sys.maxint + 1L
> 2147483648

This looks like a Python bug to me.  It attempts to 
access sys.argv[0]
while it doesn't exist.  I could solve it by patching the 
Python
library:

*** /usr/local/lib/python2.3/warnings.py~       Mon Nov 
10 11:27:00 2003
--- /usr/local/lib/python2.3/warnings.py        Mon Nov 
10 11:27:05 2003
***************
*** 49,55 ****
          if fnl.endswith(".pyc") or fnl.endswith(".pyo"):
              filename = filename[:-1]
      else:
!         if module == "__main__":
              filename = sys.argv[0]
          if not filename:
              filename = module
--- 49,55 ----
          if fnl.endswith(".pyc") or fnl.endswith(".pyo"):
              filename = filename[:-1]
      else:
!         if module == "__main__" and 
sys.__dict__.has_key("argv"):
              filename = sys.argv[0]
          if not filename:
              filename = module

> 2) Now, the Python automatically correct this problem, 
by converting
>    numbers in longinteger format.
> >>> sys.maxint + 1
> 2147483648L

Apparently it also generates a warning message.  After 
applying the
above patch the result is printed as expected.

> I think, really this is only one error: vim, for some 
strange reason,
> generate wrong exception and Python can't catch 
them.

No, the Python library accesses a member of the sys 
module that doesn't
exist.

-- 


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-11-10 09:58

Message:
Logged In: YES 
user_id=33168

Duplicate of 839151.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=839200&group_id=5470



More information about the Python-bugs-list mailing list