Elderl23 / pyfpdf

Automatically exported from code.google.com/p/pyfpdf
GNU Lesser General Public License v3.0
0 stars 0 forks source link

sub() got an unexpected keyword argument 'flags' #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run in python2.6
2. There are four lines of code that look like this:
color += re.sub('(.).',lambda m: m.group(1),line, flags=re.DOTALL)
3. Observe a crash, as the flags parameter was introduced in the sub() method 
in Python 2.7

What version of the product are you using? On what operating system?
1.7 on Linux

Please provide any additional information below.

I think this can be fixed like this:

foo = re.compile('(.{3}).',  flags=re.DOTALL)
color += foo.sub(lambda m: m.group(1),line) 

Original issue reported on code.google.com by tha...@diacakis.com on 18 Jan 2013 at 4:36

GoogleCodeExporter commented 8 years ago
Confirmed, changing the re code like this, fixes it for 2.6.

Outside the for loop:
re1 = re.compile('(.).', flags=re.DOTALL)
re2 = re.compile('.(.)', flags=re.DOTALL)

Inside the for loop:
color += re1.sub(lambda m: m.group(1),line)
alpha += re2.sub(lambda m: m.group(1),line)

Same deal on the next set:

re1 = re.compile('(.{3}).', flags=re.DOTALL)
re2 = re.compile('.{3}(.)', flags=re.DOTALL)

color += re1.sub(lambda m: m.group(1),line)
alpha += re2.sub(lambda m: m.group(1),line)

Original comment by tha...@diacakis.com on 18 Jan 2013 at 4:48

GoogleCodeExporter commented 8 years ago
Issue 47 has been merged into this issue.

Original comment by reingart@gmail.com on 14 Feb 2013 at 6:31