Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Lele Gaifax
Serhiy Storchaka writes: > Seems the documentation is not accurate. Could you file a report on > https://bugs.python.org/ ? Thank you everybody answered! Here it is: http://bugs.python.org/issue28450 ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanu

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Peter Otten
Serhiy Storchaka wrote: > On 14.10.16 20:01, Peter Otten wrote: > def double_bs(s): return "".join(s.split("\\")) >> ... > Just use s.replace('\\', r'\\'). D'oh! -- https://mail.python.org/mailman/listinfo/python-list

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Serhiy Storchaka
On 14.10.16 19:15, Chris Angelico wrote: I wasn't specifically aware that the re module was doing the same thing, but it'll be from the same purpose and goal. The idea is that, for instance, Windows path names in non-raw string literals will no longer behave differently based on whether the path

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Serhiy Storchaka
On 14.10.16 20:01, Peter Otten wrote: Lele Gaifax wrote: So, how am I supposed to achieve the mentioned intent? By doubling the escape in the replacement? If there are no escape sequences aimed to be handled by re.sub() you can escape the replacement wholesale: re.sub(r'\s+', re.escape(r'\s+

Re: Different behaviour of regexp in 3.6.0b2

2016-10-15 Thread Serhiy Storchaka
On 14.10.16 18:40, Lele Gaifax wrote: Hi all, trying out pgcli with Python 3.6.0b2 I got an error related to what seem a different behaviour, or even a bug, of re.sub(). The original intent is to replace spaces within a string with the regular expression \s+ (see https://github.com/dbcli/pgcl

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 4:48 AM, Ned Batchelder wrote: > On Friday, October 14, 2016 at 1:27:09 PM UTC-4, Chris Angelico wrote: >> On Sat, Oct 15, 2016 at 4:12 AM, Ned Batchelder >> wrote: >> > There doesn't seem to be a change to string literals at all. It's only a >> > change in the regex engi

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Ned Batchelder
On Friday, October 14, 2016 at 1:27:09 PM UTC-4, Chris Angelico wrote: > On Sat, Oct 15, 2016 at 4:12 AM, Ned Batchelder > wrote: > > There doesn't seem to be a change to string literals at all. It's only a > > change in the regex engine. > > > > Python 3.6.0b2 (default, Oct 10 2016, 21:30:05

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Ned Batchelder writes: > On Friday, October 14, 2016 at 12:50:44 PM UTC-4, Lele Gaifax wrote: >> Chris Angelico writes: >> >> > There's a shift as of 3.6 to make unrecognized alphabetic escapes into >> > errors, or at least warnings. >> >> But we are talking about raw strings here, specificall

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 4:12 AM, Ned Batchelder wrote: > There doesn't seem to be a change to string literals at all. It's only a > change in the regex engine. > > Python 3.6.0b2 (default, Oct 10 2016, 21:30:05) > [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin > Typ

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Ned Batchelder
On Friday, October 14, 2016 at 1:00:12 PM UTC-4, Chris Angelico wrote: > On Sat, Oct 15, 2016 at 3:45 AM, Lele Gaifax wrote: > > Chris Angelico writes: > > > >> There's a shift as of 3.6 to make unrecognized alphabetic escapes into > >> errors, or at least warnings. > > > > But we are talking abo

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Ned Batchelder
On Friday, October 14, 2016 at 12:50:44 PM UTC-4, Lele Gaifax wrote: > Chris Angelico writes: > > > There's a shift as of 3.6 to make unrecognized alphabetic escapes into > > errors, or at least warnings. > > But we are talking about raw strings here, specifically r'\s+'. > > I agree that with

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Peter Otten
Lele Gaifax wrote: > Peter Otten <__pete...@web.de> writes: > >> Lele Gaifax wrote: >> >>> The original intent is to replace spaces within a string with the >>> regular expression \s+ (see >>> ... >>> Accordingly to the documentation >>> (https://docs.python.org/3.6/library/re.html#re.sub) “unkno

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 3:45 AM, Lele Gaifax wrote: > Chris Angelico writes: > >> There's a shift as of 3.6 to make unrecognized alphabetic escapes into >> errors, or at least warnings. > > But we are talking about raw strings here, specifically r'\s+'. > > I agree that with plain strings it's a

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Lele Gaifax writes: > And the documentation as well, to clarify the fact immediately, without > assuming one will scroll down to the "changed in version" part (at least, that > is what seem the rule in other parts of the manual). Also, I'd prefer the "Changed in 3.6" be less ambiguous whether it

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Chris Angelico writes: > There's a shift as of 3.6 to make unrecognized alphabetic escapes into > errors, or at least warnings. But we are talking about raw strings here, specifically r'\s+'. I agree that with plain strings it's a plus. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di q

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Peter Otten <__pete...@web.de> writes: > Lele Gaifax wrote: > >> The original intent is to replace spaces within a string with the regular >> expression \s+ (see >> ... >> Accordingly to the documentation >> (https://docs.python.org/3.6/library/re.html#re.sub) “unknown escapes [in >> the repl argu

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Peter Otten
Lele Gaifax wrote: > Hi all, > > trying out pgcli with Python 3.6.0b2 I got an error related to what seem a > different behaviour, or even a bug, of re.sub(). > > The original intent is to replace spaces within a string with the regular > expression \s+ (see > https://github.com/dbcli/pgcli/blo

Re: Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Chris Angelico
On Sat, Oct 15, 2016 at 2:40 AM, Lele Gaifax wrote: > Accordingly to the documentation > (https://docs.python.org/3.6/library/re.html#re.sub) > “unknown escapes [in the repl argument] such as \& are left alone”. > > Am I missing something, or is this a regression? Further down, you'll find this

Different behaviour of regexp in 3.6.0b2

2016-10-14 Thread Lele Gaifax
Hi all, trying out pgcli with Python 3.6.0b2 I got an error related to what seem a different behaviour, or even a bug, of re.sub(). The original intent is to replace spaces within a string with the regular expression \s+ (see https://github.com/dbcli/pgcli/blob/master/pgcli/packages/prioritizat