[Python-mode] [Bug 450552] Re: python-mode breaks for python 3
Andreas Roehler
andreas.roehler at online.de
Thu Oct 22 14:13:16 CEST 2009
Rustom Mody wrote:
> On Tue, Oct 20, 2009 at 1:59 PM, Andreas Roehler
> <andreas.roehler at online.de <mailto:andreas.roehler at online.de>> wrote:
>
> Rustom wrote:
> > (cmd (format "exec(compile(open('%s').read(), '%s', 'exec')) #
> > PYTHON-MODE\n" filename filename)))
For me both of your variants are working, see output of checks below.
uname -a && python --version && cat 2+4.py && cat exec-read.py && python exec-read.py &&
cat exec-compile-read.py && python exec-compile-read.py
==>
Linux ... 2.6.22.19-0.2-default #1 SMP 2008-12-18 10:17:03 +0100 i686 athlon i386 GNU/Linux
Python 2.5.1
#! /usr/bin/env python
# -*- coding: utf-8 -*-
print 2 + 4
##################
#! /usr/bin/env python
# -*- coding: utf-8 -*-
exec(open('2+4.py').read())
######################
6
#! /usr/bin/env python
# -*- coding: utf-8 -*-
exec(compile(open('2+4.py').read(), '2+4.py', 'exec'))
#################
6
;;;;;;;;;;;;;;;;;
BTW can you tell whats the us of `compile' here for you?
Do you have some tests for python-mode.el?
> 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
>
>
> See Guido's 2 to 3 doc
> http://docs.python.org/dev/3.0/whatsnew/3.0.html#removed-syntax
> says stream argument not taken
>
>
Ah, thanks
Andreas
More information about the Python-mode
mailing list