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: re.sub(r'\\', r'\\\\', s) reporting MemoryError
Type: resource usage Stage: resolved
Components: Regular Expressions Versions: Python 3.7, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Guruprasad Venkataramaiah, ezio.melotti, mrabarnett, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-09-01 10:55 by Guruprasad Venkataramaiah, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg350943 - (view) Author: Guruprasad Venkataramaiah (Guruprasad Venkataramaiah) Date: 2019-09-01 10:55
On Python 3.5:
s = re.sub(r'\\', r'\\\\', s)
  File "/pyuniti/venvs/guruv/lib/python3.5/re.py", line 182, in sub
    return _compile(pattern, flags).sub(repl, string, count)
MemoryError

On Python 3.7
    s = re.sub(r'\\', r'\\\\', s)  
  File "C:\Python\Python37-32\lib\re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
MemoryError
msg350944 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-01 11:00
What is s?
msg350948 - (view) Author: Guruprasad Venkataramaiah (Guruprasad Venkataramaiah) Date: 2019-09-01 12:15
With more debug, observed the input string ('s') is getting assigned to a big string of '////' resulting in Memory error
msg350949 - (view) Author: Guruprasad Venkataramaiah (Guruprasad Venkataramaiah) Date: 2019-09-01 12:17
With more debug, observed the input string ('s') is getting assigned to a big string of '////' resulting in Memory error
History
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82179
2019-09-01 12:17:04Guruprasad Venkataramaiahsetstatus: open -> closed

messages: + msg350949
stage: resolved
2019-09-01 12:15:52Guruprasad Venkataramaiahsetresolution: not a bug
messages: + msg350948
2019-09-01 11:00:11serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg350944
2019-09-01 10:55:51Guruprasad Venkataramaiahcreate