[ python-Bugs-1519638 ] Unmatched Group issue

2007-02-15 Thread SourceForge.net
Bugs item #1519638, was opened at 2006-07-09 14:34
Message generated for change (Comment added) made by mchaput
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1519638&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Regular Expressions
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Bobby Xiao (nneonneo)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: Unmatched Group issue

Initial Comment:
Using sre.sub[n], an "unmatched group" error can occur.

The test I used is this pattern:

sre.sub("foo(?:b(ar)|baz)","\\1","foobaz")

This will cause the following backtrace to occur:

Traceback (most recent call last):
  File "", line 1, in ?
  File "lib/python2.4/sre.py", line 142, in sub
return _compile(pattern, 0).sub(repl, string, count)
  File "lib/python2.4/sre.py", line 260, in filter
return sre_parse.expand_template(template, match)
  File "lib/python2.4/sre_parse.py", line 782, in expand_template
raise error, "unmatched group"
sre_constants.error: unmatched group

Python Version 2.4.3, Mac OS X (behaviour has been verified on 
Windows 2.4.3 as well).

This behaviour, while by design, is unwanted because this type of 
matching usually requests that a blank match be returned (i.e. the 
example should return '')

The example that I was trying resembles the following:

sre.sub("User: (?:Registered User #(\d+)|Guest)","%USERID|\1%",data)

The intended behaviour is that the function returns "" when the user is 
a guest and the user number if the user is a registered member.

However, when this function encounters a Guest, it raises an exception 
and terminates, which is not what is wanted.

Perl and other regex engines behave as I have described, substituting 
empty strings for unmatched groups. The code fix is relatively simple, 
and would really help out for these types of things.

--

Comment By: Matt Chaput (mchaput)
Date: 2007-02-15 13:35

Message:
Logged In: YES 
user_id=1249840
Originator: NO

The current behavior also makes the "sub" function useless when you need
to backreference a group that might not capture, since you have no chance
to deal with the exception.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1519638&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1661108 ] base64.urlsafe_b64encode() shouldn't use the = character

2007-02-15 Thread SourceForge.net
Bugs item #1661108, was opened at 2007-02-16 03:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1661108&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Ryan Barrett (ryanbarrett)
Assigned to: Nobody/Anonymous (nobody)
Summary: base64.urlsafe_b64encode() shouldn't use the = character

Initial Comment:
base64.urlsafe_b64encode() almost always returns strings that include the = 
character. this may be ok before the ? in a URL, but it's not OK after.

it would be nice if it substituted another character for =, like it does for + 
and /. if this is intentional, though, and you don't want to substitute for =, 
the documentation should probably be changed to note that it's only safe for 
use before the ?. (it doesn't include that caveat now.)

http://docs.python.org/lib/module-base64.html#l2h-1592

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1661108&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com