olopez32 / tinypy

Automatically exported from code.google.com/p/tinypy
Other
0 stars 0 forks source link

index function hangs and gives bus error for substrings that can't be found #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. "test-".index("=")

What is the expected output? What do you see instead?
CPython gives "ValueError: substring not found" almost immediately.
tinypy hangs for a few seconds and says "Bus error"

It looks like the search isn't terminating at the end of the string. The
code for tp_index seems to want to return -1 for substrings that can't be
found, but for some reason it doesn't get there.

Original issue reported on code.google.com by ulf...@gmail.com on 30 May 2008 at 1:38

GoogleCodeExporter commented 9 years ago
I put a print in tp_str_index() after the call to _tp_str_index().  It does 
indeed 
return -1.  I believe the trouble is that the var-arguments passed to 
tp_raise() are of 
type tp_obj rather that pointers to C strings.  The attached patch seems to 
work for 
the test case.

Original comment by dwhall...@gmail.com on 30 May 2008 at 5:16

Attachments:

GoogleCodeExporter commented 9 years ago
To complete this patch can you include the test case in tests.py?

Thanks!

Original comment by philhas...@gmail.com on 1 Jun 2008 at 3:23

GoogleCodeExporter commented 9 years ago
I added a test case.  I also had to make a small fix to the TINYPY path in 
tests.py so 
that all t_boot() tests would run (can someone please check that the tests pass 
on 
linux).  New patch attached to issue.

Original comment by dwhall...@gmail.com on 1 Jun 2008 at 3:34

Attachments:

GoogleCodeExporter commented 9 years ago
The issue with the path needs to be handled in a separate issue since it is 
unrelated
and especially since this change actually breaks how the bootstrapping process 
works
under linux.

Original comment by philhas...@gmail.com on 1 Jun 2008 at 4:30

GoogleCodeExporter commented 9 years ago
Applied fix (sans the bootstrapping related change)

Original comment by philhas...@gmail.com on 1 Jun 2008 at 5:02