Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken pre.subn() (and pre.sub()) #36761

Closed
tuben mannequin opened this issue Jun 17, 2002 · 3 comments
Closed

Broken pre.subn() (and pre.sub()) #36761

tuben mannequin opened this issue Jun 17, 2002 · 3 comments

Comments

@tuben
Copy link
Mannequin

tuben mannequin commented Jun 17, 2002

BPO 570057

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2002-06-27.20:19:52.000>
created_at = <Date 2002-06-17.14:27:33.000>
labels = ['expert-regex']
title = 'Broken pre.subn() (and pre.sub())'
updated_at = <Date 2002-06-27.20:19:52.000>
user = 'https://bugs.python.org/tuben'

bugs.python.org fields:

activity = <Date 2002-06-27.20:19:52.000>
actor = 'effbot'
assignee = 'effbot'
closed = True
closed_date = None
closer = None
components = ['Regular Expressions']
creation = <Date 2002-06-17.14:27:33.000>
creator = 'tuben'
dependencies = []
files = []
hgrepos = []
issue_num = 570057
keywords = []
message_count = 3.0
messages = ['11229', '11230', '11231']
nosy_count = 2.0
nosy_names = ['effbot', 'tuben']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue570057'
versions = ['Python 2.2']

@tuben
Copy link
Mannequin Author

tuben mannequin commented Jun 17, 2002

The functions pre.subn() and pre.sub() are broken in
Python2.2 and 2.2.1. The following test was done on
SunOS 5.6:

Python 2.2.1 (#1, Jun 13 2002, 12:57:34) 
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for
more information.
>>> import re
>>> re.sub('(a)', '\g<1>', 'bab')
'bab'
>>> import pre as re
>>> re.sub('(a)', '\g<1>', 'bab')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/tools/lib/python2.2/pre.py", line
179, in sub
    return pattern.sub(repl, string, count)
  File "/usr/local/tools/lib/python2.2/pre.py", line
344, in sub
    return self.subn(repl, string, count)[0]
  File "/usr/local/tools/lib/python2.2/pre.py", line
366, in subn
    repl = pcre_expand(_Dummy, repl)
TypeError: 'NoneType' object is not callable

The error has also been reproduced on SunOS5.7 with the
following interpreter:
Python 2.2 (#1, Dec 28 2001, 22:25:04)
[GCC 2.95.2 19991024 (release)] on sunos5

The error could not be reproduced on SunOS5.6 using
Python2.1.1:
Python 2.1.1 (#5, Sep 10 2001, 13:44:17)
[GCC 2.95.2 19991024 (release)] on sunos5

NOTE: The example for re.sub() in the Python Library
manual triggers this bug when used with module pre!

@tuben tuben mannequin closed this as completed Jun 17, 2002
@tuben tuben mannequin assigned effbot Jun 17, 2002
@tuben tuben mannequin added the topic-regex label Jun 17, 2002
@tuben tuben mannequin closed this as completed Jun 17, 2002
@tuben tuben mannequin assigned effbot Jun 17, 2002
@tuben tuben mannequin added the topic-regex label Jun 17, 2002
@effbot
Copy link
Mannequin

effbot mannequin commented Jun 27, 2002

Logged In: YES
user_id=38376

someone who didn't understand the code changed an
"except" to "except error", and the test suite doesn't
spend much energy checking that PRE works as it
should... :-(

(as a workaround, change the line after the "pcre_expand"
call to "except:")

</F>

@effbot
Copy link
Mannequin

effbot mannequin commented Jun 27, 2002

Logged In: YES
user_id=38376

fixed in CVS

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants