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: [OSF1 alpha] string.replace()
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: martin_casado, mwh, tim.peters
Priority: normal Keywords:

Created on 2001-05-07 18:25 by martin_casado, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (11)
msg4664 - (view) Author: Martin Casado (martin_casado) Date: 2001-05-07 18:25
>>> import sys
>>> sys.version
'2.0c1 (#7, Jan 24 2001, 15:36:12) [C]'
>>> s = "123"
>>> s.replace("123","")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
MemoryError
>>> os.uname()
('OSF1', 'xxx', 'V4.0', '1229', 'alpha')
>>> 


I haven't tried it with anything newer, perhaps this
bug
has already been posted and/or fixed, though I couldn't
find it in the buglist
msg4665 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-08 02:58
Logged In: YES 
user_id=31435

Works for me.  Please try recompiling with optimization 
turned off.  If that makes the problem go away (seems 
likely to me), it's a platform compiler bug.
msg4666 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2001-05-08 07:34
Logged In: YES 
user_id=6656

FWIW, I can (a) reproduce this on alpha/OSF1 (recompiling
stringobject.c without optimizations makes no odds,
recompiling all of Python takes too long on this particular
alpha) (b) make it go away by replacing the call to
PyMem_MALLOC in mymemreplace with one to PyMem_Malloc.

The difference is that PyMem_Malloc(0) can't be NULL;
PyMem_MALLOC can.

So either do this, or check if new_len is zero and return
PyString_FromString("") or something (in mymemreplace).
msg4667 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2001-05-08 14:51
Logged In: YES 
user_id=6656

FWIW, I can (a) reproduce this on alpha/OSF1 (recompiling
stringobject.c without optimizations makes no odds,
recompiling all of Python takes too long on this particular
alpha) (b) make it go away by replacing the call to
PyMem_MALLOC in mymemreplace with one to PyMem_Malloc.

The difference is that PyMem_Malloc(0) can't be NULL;
PyMem_MALLOC can.

So either do this, or check if new_len is zero and return
PyString_FromString("") or something (in mymemreplace).
msg4668 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-09 23:01
Logged In: YES 
user_id=31435

Good eye, Michael!  I've checked in what I hope will be a 
fix:

Lib/test/string_tests.py new revision: 1.8
Modules/stropmodule.c new revision: 2.77

Please give that a try and let me know whether it fixes the 
problem on this box.
msg4669 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2001-05-10 07:11
Logged In: YES 
user_id=6656

yep, fixes it.  doesn't fix strop, but I think that's
deliberate?
msg4670 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-10 09:02
Logged In: YES 
user_id=31435

Sorry, don't know what "doesn't fix strop" means.  What's 
broken in strop?  The test case didn't use strop (although 
I mentioned stropmodule.c in a comment).  Closing the bug 
assuming this is some misunderstanding that's not worth the 
time to straighten out <0.7 wink>; please re-open if you 
think it is.
msg4671 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2001-05-10 10:45
Logged In: YES 
user_id=6656

I meant:

Python 2.2a0 (#3, May 10 2001, 07:57:08) [C] on osf1V4
Type "copyright", "credits" or "license" for more information.
>>> import strop
>>> strop.replace("123","123","")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
MemoryError

as I said, I thought this was expected, but thought I'd check (I 
did put a comment in yesterday that explained what I meant more
thouroughly, but sf ate it).
msg4672 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-05-10 16:12
Logged In: YES 
user_id=31435

Ah!  No, I do NOT expect that.  The copies of mymemreplace
() in stringobject.c and stropmodule.c were (eventually) 
both replaced, and that was the source of the MemoryError.  
Did you have up-to-date versions of both?  If so, this is 
some other bug!  The only occurrence of PyMem_MALLOC() in 
stropmodule.c "got fixed".
msg4673 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2001-05-10 18:37
Logged In: YES 
user_id=6656

doh! i'd only updated stringobject.c.

sorry for being a doofus.  it all works now.
msg4674 - (view) Author: Martin Casado (martin_casado) Date: 2001-05-10 19:03
Logged In: YES 
user_id=133423

I made the suggested changes and things are now working
grand! thanks guys.
History
Date User Action Args
2022-04-10 16:04:02adminsetgithub: 34468
2001-05-07 18:25:12martin_casadocreate