This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Odd warning behaviors
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, georg.brandl, mwh, tim.peters
Priority: normal Keywords:

Created on 2004-02-03 22:25 by tim.peters, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
range-warnings-fixes.diff mwh, 2004-02-04 15:05 right file this time (still fix #1)
Messages (10)
msg19899 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-02-03 22:25
This is from Evan Simpson, on the zope-dev list.  The 
bulk have to do with what happens if __name__ is set to 
None:


Subject: Re: [Zope-dev] Re: Zope 2.7.0 rc2 + python 
2.3.3 problem
http://mail.zope.org/mailman/listinfo/zope-dev

Python 2.3.3 (#2, Jan 13 2004, 00:47:05)
[GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
 >>> range(1.0)
__main__:1: DeprecationWarning: integer argument 
expected, got float
[0]
 >>>

So far, so good.  However:

Python 2.3.3 (#2, Jan 13 2004, 00:47:05)
[GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
 >>> __name__=None
 >>> range(1.0)
[]
 >>> 1+1
Traceback (most recent call last):
   File "/usr/lib/python2.3/warnings.py", line 57, in warn
     warn_explicit(message, category, filename, lineno, 
module, registry)
   File "/usr/lib/python2.3/warnings.py", line 63, in 
warn_explicit
     if module[-3:].lower() == ".py":
TypeError: unsubscriptable object
 >>>

...and...

Python 2.3.3 (#2, Jan 13 2004, 00:47:05)
[GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
 >>> import warnings
 >>> warnings.simplefilter("error", 
category=DeprecationWarning)
 >>> range(1.0)
[]
 >>> 1+1
Traceback (most recent call last):
   File "/usr/lib/python2.3/warnings.py", line 57, in warn
     warn_explicit(message, category, filename, lineno, 
module, registry)
   File "/usr/lib/python2.3/warnings.py", line 92, in 
warn_explicit
     raise message
DeprecationWarning: integer argument expected, got 
float
 >>>

...and...

Python 2.3.3 (#2, Jan 13 2004, 00:47:05)
[GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
 >>> import pdb
 >>> __name__ = None
 >>> pdb.run('range(1.0)')
 > <string>(1)?()
(Pdb) s
--Call--
 > /usr/lib/python2.3/warnings.py(24)warn()
-> def warn(message, category=None, stacklevel=1):
(Pdb) r
--Return--
/usr/lib/python2.3/bdb.py:302: RuntimeWarning: 
tp_compare didn't return 
-1 or -2 for exception
   i = max(0, len(stack) - 1)
[traceback snipped]

Looks like something isn't properly propagating 
exceptions.

Cheers,

Evan @ 4-am
msg19900 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-02-04 12:10
Logged In: YES 
user_id=6656

Might this be specific to range()?

[mwh@pc150 build]$ ./python.exe -Werror
Python 2.4a0 (#3, Feb  3 2004, 19:23:25) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
Type "help", "copyright", "credits" or "license" for more 
information.
>>> range(5.0)
[]

range()'s argument handling is somewhat odd
msg19901 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-02-04 13:22
Logged In: YES 
user_id=6656

OK, the problem is that returning NULL from 
getargs.c:convertsimple indicates *success* (argh!).

Fixing that provokes weird errors from handle_range_longs.
msg19902 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-02-04 15:03
Logged In: YES 
user_id=6656

How's this?  It's horrible, but I'm not sure that can be avoided.
msg19903 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-02-04 15:05
Logged In: YES 
user_id=6656

Oops, wrong file.
msg19904 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-02-12 14:09
Logged In: YES 
user_id=6656

Is anyone listening?
msg19905 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-02-17 00:51
Logged In: YES 
user_id=31435

I'm listening, but with half of part of one ear.  Have to agree 
convertsimple() was wrong in these cases, but can't make 
time for more than that.  Reassigned to Jeremy, partly at 
random (his is one of the names that shows up as a recent 
getargs.c changer).
msg19906 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-10 22:28
Logged In: YES 
user_id=1188172

In current SVN heads, range(1.0) gives DeprecationWarning and 
__name__=None; range(1.0) gives TypeError.

Is this okay?
msg19907 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-01-17 21:53
Logged In: YES 
user_id=31435

No, it's certainly not OK for range(1.0) to raise either
DeprecationWarning or TypeError depending on what __name__
happens to be.  But I may not understand what you mean. 
This is a screen scrape from current SVN trunk, on Windows:

>>> __name__ = None; range(1.0)
None:1: DeprecationWarning: integer argument expected, got float
[0]

I don't see TypeError there, so I'm not sure what

"""
In current SVN heads, range(1.0) gives DeprecationWarning and 
__name__=None; range(1.0) gives TypeError.
"""

means.
msg19908 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-18 18:38
Logged In: YES 
user_id=1188172

I fixed warnings inbetween, see revision 42028.

So I guess this can be closed.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39898
2004-02-03 22:25:07tim.peterscreate