[issue12636] IDLE ignores -*- coding -*- with -r option

2011-07-25 Thread ledave123

New submission from ledave123 :

I'm on Windows with cp1252 as the default encoding.
When I use -*- coding: c1252 -*- I get no problems.
When I use -*- coding: utf-8 -*- IDLE -r still opens the file with cp1252 
encoding.
Python.exe opens the file with utf-8 correctly.

I think the problem is in Python32\Lib\idlelib\PyShell.py line 585:
In class ModifiedInterpreter:

def execfile(self, filename, source=None):
"Execute an existing file"
if source is None:
source = open(filename, "r").read() # this is the bug IMHO

--
components: IDLE
messages: 141081
nosy: ledave123
priority: normal
severity: normal
status: open
title: IDLE ignores -*- coding -*- with -r option
type: behavior
versions: Python 3.2

___
Python tracker 
<http://bugs.python.org/issue12636>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12636] IDLE ignores -*- coding -*- with -r option

2011-07-28 Thread ledave123

ledave123  added the comment:

The problem can be fixed with tokenize :
I'm sorry I never submitted a path and I have no access to the source tree from 
here, if someone cares to do it, do not hesitate.

def execfile(self, filename, source=None):
"Execute an existing file"
if source is None:
import tokenize
source = tokenize.open(filename).read()

--

___
Python tracker 
<http://bugs.python.org/issue12636>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12636] IDLE ignores -*- coding -*- with -r option

2011-08-31 Thread ledave123

ledave123  added the comment:

Here is the patch:

diff -r e8da570d29a8 Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.pyWed Jul 27 21:28:23 2011 +0200
+++ b/Lib/idlelib/PyShell.pyWed Aug 31 20:16:38 2011 +0200
@@ -582,7 +582,9 @@
 def execfile(self, filename, source=None):
 "Execute an existing file"
 if source is None:
-source = open(filename, "r").read()
+import tokenize
+with tokenize.open(filename) as filein:
+source = filein.read()
 try:
 code = compile(source, filename, "exec")
 except (OverflowError, SyntaxError):

Sorry for taking such a long time, I was on holidays.

--
resolution:  -> works for me

___
Python tracker 
<http://bugs.python.org/issue12636>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7298] reversed(range(x, -1, -1)) is empty when x > 1

2009-11-10 Thread ledave123

New submission from ledave123 :

On python 2.4.4, reversed(range()) is correct :
>>> list(reversed(range(12,-1,-1)))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

However, on python 3.1.1 :
>>> list(reversed(range(12,-1,-1)))
[]
which is obviously wrong.

When step is positive, the result is okay on python 3.1.1 :
>>> list(reversed(range(13)))
[12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

--
components: Interpreter Core
messages: 95104
nosy: ledave123
severity: normal
status: open
title: reversed(range(x, -1, -1)) is empty when x > 1
type: behavior
versions: Python 3.1

___
Python tracker 
<http://bugs.python.org/issue7298>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com