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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Andreas Röhler-2
Rustom wrote:

> Public bug reported:
>
> python 3 has removed execfile
> This makes python-mode stop working
>
> In function py-execute-file changing the line
>
> (cmd (format "execfile(r'%s') # PYTHON-MODE\n" filename)))
>
> to
> (cmd (format "exec(open(r'%s').read()) # PYTHON-MODE\n" filename)))
>
> seems to solve the problem
>
> ** Affects: python-mode
>      Importance: Undecided
>          Status: New
>



IMO it's not to cure by changing a line in general.

More bugs will be around due to different flavours of python.

Versions of python 2.4.+ are in use still AFAIK.
2.5.+ or 2.6.+ will remain widely used

Will a single python-mode be able to cope with this differences?

IMHO: yes, however it must to address some issues.

Herewith some outlines what seems necessary:

- specifying by a variable the version where edits are for  (customizable)

- some guessing, which python-version might be in used, if user didn't set it

- displaying python-versions-variable in mode-line

- auto-adapting code, editing and execution resp. to the mentioned version.

- possible switch between versions-specifics, updating the modeline etc.


Introducing a first item in this line might read:

(defcustom py-adressed-python-version ""
  "*With different Python versions, changes have been made, which affect python execution as editing likewise.
If a version is specified here, python-mode will adapt its proceeding to it.
Otherwise python-mode will try some guess from the installed system.
You may switch the addressed python-version with M-x py-switch-addressed-version during your emacs-session. "
  :type 'string
  :group 'python)

Any hints, objections, ideas?

Thanks!


Andreas

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



_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode
Reply | Threaded
Open this post in threaded view
|

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

Barry Warsaw
On Oct 17, 2009, at 11:54 AM, Andreas Roehler wrote:

>
> (defcustom py-adressed-python-version ""
>  "*With different Python versions, changes have been made, which  
> affect python execution as editing likewise.
> If a version is specified here, python-mode will adapt its  
> proceeding to it.
> Otherwise python-mode will try some guess from the installed system.
> You may switch the addressed python-version with M-x py-switch-
> addressed-version during your emacs-session. "
>  :type 'string
>  :group 'python)
>
> Any hints, objections, ideas?

I'd definitely love to see some enhancements to python-mode to deal  
with Python 3, but of course I have no time for that myself. ;)

I'd suggest two variables:

(defvar py-python-major-version ...)

This would be a buffer-local variable, defaulting to "2", specifying  
the Python major version of the code in the current buffer.

(defcustom py-guess-python-version ...)

This would be a global customizable variable specifying whether to  
apply heuristics to guess the py-python-major-version when a buffer is  
visited.  It should probably default to t.

+1 for working on this!
-Barry


_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode