[New-bugs-announce] [issue12492] Inconsistent Python find() behavior

Juan Gonzalez report at bugs.python.org
Mon Jul 4 23:48:38 CEST 2011

New submission from Juan Gonzalez <juan.gonzalez at ti.com>:

Something really weird going on in python find() string function.  When I call <string>.find() and python returns -1 it crashes when compared against 0 using the ">" operator.

The statement in which crash condition occurs is the following:

    if url.find(str) > 0:
        print "RSS Item:", url

However, if I change the statement to be "<" instead it does not crash.
The error that the python compiler reports is:

AttributeError: 'int' object has no attribute 'find'

My version of python is:

tony at ubuntu:~/auto/sel/scripts$ python -V
Python 2.7.1+

components: Regular Expressions
messages: 139810
nosy: juan.gonzalez
priority: normal
severity: normal
status: open
title: Inconsistent Python find() behavior
type: crash
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list