[Python-mode] [Bug 450552] Re: python-mode breaks for python 3

Andreas Roehler andreas.roehler at online.de
Tue Oct 20 10:29:16 CEST 2009


Rustom wrote:
> Right now the mc Im on does not have python 2.x and python3
> 
> But when I was on a debian box with 2.5 and 3
> changing
> 
> (cmd (format "execfile(r'%s') # PYTHON-MODE\n" filename)))
> 
> to
> 
> (cmd (format "exec(compile(open('%s').read(), '%s', 'exec')) # 
> PYTHON-MODE\n" filename filename))) 
> 
> [ not
> 
> (cmd (format "exec(open(r'%s').read()) # PYTHON-MODE\n" filename)))
> as my original post suggested]
> 
> seemed to work for both 2.5 and 3
> 
> Whether other changes from 2.x to 3 will introduce breakage in python-
> mode I dont know
> 
> The more important question remaining about my suggested fix is about windows.
> Evidently there is some stupidity that exec expects its input to have unix line endings even on windows so the original code may not work on windows but the one with compile should.
> 
> But Ive not tested on windows
> 


Hi Rustom,

looks like good news. Think you are right.

Checked a little bit with
Python 2.5.1
on Linux 2.6.22.19-0.2-default #1 SMP 2008-12-18 10:17:03 +0100 i686 athlon i386 GNU/Linux

works fine AFAIS.

What puzzles me still is a pure python question -

do we need this `read()' here, i.e. if a file opened is
delivered to exec, will it not being read anyway?

Thanks

Andreas

--
https://code.launchpad.net/s-x-emacs-werkstatt/
http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/





More information about the Python-mode mailing list