Issue 121612 - Mail merge broken due to Python3 conversion
Mail merge broken due to Python3 conversion
Status: RESOLVED FIXED
Product: General
Classification: Code
Component: scripting
3.4.1
All All
: P3 normal (vote)
: 4.0.0
Assigned To: Ariel Constenla-Haile
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-01-11 21:29 UTC by Ariel Constenla-Haile
Modified: 2013-01-14 15:18 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation on: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ariel Constenla-Haile 2013-01-11 21:29:07 UTC
1 seems to have applied the "2to3 source-to-source conversion tool, all print statements are automatically converted to print() function calls, so this is mostly a non-issue for larger projects."

http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function

Converting statements as the following:

Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)

print("fatal error", file=sys.stderr) is no valid Python 2 syntax, so this broke mailmerge.py
Comment 1 SVN Robot 2013-01-13 17:31:46 UTC
"arielch" committed SVN 0 into trunk:
i121612 - Fix broken python mail component
Comment 2 Ariel Constenla-Haile 2013-01-13 17:35:52 UTC
Fixed by replacing 

print( "$STRING", file=sys.stderr)

only valid in Python3, with

out = sys.stderr
out.write("$STRING\n")

that works both in Python2 and Python3.

I only checked the mail component, but other stuff might be broken to.
Comment 3 Pedro Giffuni 2013-01-14 15:18:59 UTC
(In reply to comment #2)
> Fixed by replacing 
> 
> print( "$STRING", file=sys.stderr)
> 
> only valid in Python3, with
> 
> out = sys.stderr
> out.write("$STRING\n")
> 
> that works both in Python2 and Python3.
> 
> I only checked the mail component, but other stuff might be broken to.

Thank you for the fix!

I opengroked "sys.stderr" and it appears it was the only case where this happened.