[issue12492] Inconsistent Python find() behavior

2011-07-04 Thread Juan Gonzalez

New submission from Juan Gonzalez :

Something really weird going on in python find() string function.  When I call 
.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
break; 

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@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 
<http://bugs.python.org/issue12492>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12492] Inconsistent Python find() behavior

2011-07-05 Thread Juan Gonzalez

Juan Gonzalez  added the comment:

Today I tried to use parse() instead of find() and I found out the following 
response:


tony@ubuntu:~/auto/sel/scripts$ python wtfibmdom
Traceback (most recent call last):
  File "wtfibmdom", line 22, in 
if url.parse(str) > 0:
AttributeError: 'str' object has no attribute 'parse'
tony@ubuntu:~/auto/sel/scripts$ python wtfibmdom
Title: j3-dcsled-prd-validation passed Fri, 01 Jul 2011 14:03:59 -0500
Description: Build passed
Traceback (most recent call last):
  File "wtfibmdom", line 22, in 
if url.find(str) > 0:
AttributeError: 'int' object has no attribute 'find'


I think this behavior is inconsistent since the compiler is treating the url 
variable as int and string at the same time.

--
status: pending -> open

___
Python tracker 
<http://bugs.python.org/issue12492>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12492] Inconsistent Python find() behavior

2011-07-05 Thread Juan Gonzalez

Juan Gonzalez  added the comment:

Hi Georg,

This is the python code listing:

from RSS import ns, CollectionChannel, TrackingChannel

#Create a tracking channel, which is a data structure that
#Indexes RSS data by item URL
tc = TrackingChannel()
str = 'j3-nspire-prd-validation'
index = 0
#Returns the RSSParser instance used, which can usually be ignored
#tc.parse("http://www.python.org/channews.rdf";)
tc.parse("http://pdt-california.eps.ti.com:8080/dashboard/rss.xml";)   

RSS10_TITLE = (ns.rss10, 'title')
RSS10_DESC = (ns.rss10, 'description')

#You can also use tc.keys()
items = tc.listItems()
for item in items:
#Each item is a (url, order_index) tuple
url = item[index]
#print "RSS Item:", 
#str.find(str, beg=0 end=len(string))
if url.find(str) > 0:
 print "RSS Item:", url
 break; 
#Get all the data for the item as a Python dictionary
index = index + 1
item_data = tc.getItem(item)
print "Title:", item_data.get(RSS10_TITLE, "(none)")
print "Description:", item_data.get(RSS10_DESC, "(none)")

--

___
Python tracker 
<http://bugs.python.org/issue12492>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12492] Inconsistent Python find() behavior

2011-07-05 Thread Juan Gonzalez

Juan Gonzalez  added the comment:

I print 1 before the faulty line and like Jesús says I'm surprised I get a 1

Description: Build passed
1
Traceback (most recent call last):
  File "wtfibmdom", line 23, in 
if url.find(str) > 0:
AttributeError: 'int' object has no attribute 'find'

--

___
Python tracker 
<http://bugs.python.org/issue12492>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com