Thread View
j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
http://hg.python.org/cpython/rev/a958b7f16a7d
changeset: 84402:a958b7f16a7d
branch: 2.7
parent: 84399:231c122b44b6
user: Terry Jan Reedy <tjreedy(a)udel.edu>
date: Sun Jun 30 19:07:49 2013 -0400
summary:
Issue #8515: Set __file__ when run file in IDLE. Backport 2c276d0553ff by
Andrew Svetlov, based on initial patch by Bruce Frederiksen.
files:
Lib/idlelib/ScriptBinding.py | 12 ++++++------
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -152,16 +152,16 @@
dirname = os.path.dirname(filename)
# XXX Too often this discards arguments the user just set...
interp.runcommand("""if 1:
- _filename = %r
+ __file__ = {filename!r}
import sys as _sys
from os.path import basename as _basename
if (not _sys.argv or
- _basename(_sys.argv[0]) != _basename(_filename)):
- _sys.argv = [_filename]
+ _basename(_sys.argv[0]) != _basename(__file__)):
+ _sys.argv = [__file__]
import os as _os
- _os.chdir(%r)
- del _filename, _sys, _basename, _os
- \n""" % (filename, dirname))
+ _os.chdir({dirname!r})
+ del _sys, _basename, _os
+ \n""".format(filename=filename, dirname=dirname))
interp.prepend_syspath(filename)
# XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still
# go to __stderr__. With subprocess, they go to the shell.
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -317,6 +317,7 @@
John Fouhy
Stefan Franke
Martin Franklin
+Bruce Frederiksen
Robin Friedrich
Bradley Froehle
Ivan Frohne
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -73,6 +73,9 @@
IDLE
----
+- Issue #8515: Set __file__ when run file in IDLE.
+ Initial patch by Bruce Frederiksen.
+
- Issue #5492: Avoid traceback when exiting IDLE caused by a race condition.
- Issue #17511: Keep IDLE find dialog open after clicking "Find Next".
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/dbdb6f7f9a1a
changeset: 84401:dbdb6f7f9a1a
parent: 84398:ae69436eb7c2
parent: 84400:c7605471e8ae
user: Terry Jan Reedy <tjreedy(a)udel.edu>
date: Sun Jun 30 18:37:51 2013 -0400
summary:
Merge with 3.3
files:
Lib/idlelib/Delegator.py | 4 +-
Lib/idlelib/idle_test/test_delegator.py | 37 +++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -4,12 +4,12 @@
def __init__(self, delegate=None):
self.delegate = delegate
- self.__cache = {}
+ self.__cache = set()
def __getattr__(self, name):
attr = getattr(self.delegate, name) # May raise AttributeError
setattr(self, name, attr)
- self.__cache[name] = attr
+ self.__cache.add(name)
return attr
def resetcache(self):
diff --git a/Lib/idlelib/idle_test/test_delegator.py b/Lib/idlelib/idle_test/test_delegator.py
new file mode 100644
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_delegator.py
@@ -0,0 +1,37 @@
+import unittest
+from idlelib.Delegator import Delegator
+
+class DelegatorTest(unittest.TestCase):
+
+ def test_mydel(self):
+ # test a simple use scenario
+
+ # initialize
+ mydel = Delegator(int)
+ self.assertIs(mydel.delegate, int)
+ self.assertEqual(mydel._Delegator__cache, set())
+
+ # add an attribute:
+ self.assertRaises(AttributeError, mydel.__getattr__, 'xyz')
+ bl = mydel.bit_length
+ self.assertIs(bl, int.bit_length)
+ self.assertIs(mydel.__dict__['bit_length'], int.bit_length)
+ self.assertEqual(mydel._Delegator__cache, {'bit_length'})
+
+ # add a second attribute
+ mydel.numerator
+ self.assertEqual(mydel._Delegator__cache, {'bit_length', 'numerator'})
+
+ # delete the second (which, however, leaves it in the name cache)
+ del mydel.numerator
+ self.assertNotIn('numerator', mydel.__dict__)
+ self.assertIn('numerator', mydel._Delegator__cache)
+
+ # reset by calling .setdelegate, which calls .resetcache
+ mydel.setdelegate(float)
+ self.assertIs(mydel.delegate, float)
+ self.assertNotIn('bit_length', mydel.__dict__)
+ self.assertEqual(mydel._Delegator__cache, set())
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2, exit=2)
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/c7605471e8ae
changeset: 84400:c7605471e8ae
branch: 3.3
parent: 84397:c17fa2cbad43
user: Terry Jan Reedy <tjreedy(a)udel.edu>
date: Sun Jun 30 18:37:05 2013 -0400
summary:
Issue #18189: add test_delegator for Idle Delegator class.
Also change private dict used as a set to a set.
files:
Lib/idlelib/Delegator.py | 4 +-
Lib/idlelib/idle_test/test_delegator.py | 37 +++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -4,12 +4,12 @@
def __init__(self, delegate=None):
self.delegate = delegate
- self.__cache = {}
+ self.__cache = set()
def __getattr__(self, name):
attr = getattr(self.delegate, name) # May raise AttributeError
setattr(self, name, attr)
- self.__cache[name] = attr
+ self.__cache.add(name)
return attr
def resetcache(self):
diff --git a/Lib/idlelib/idle_test/test_delegator.py b/Lib/idlelib/idle_test/test_delegator.py
new file mode 100644
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_delegator.py
@@ -0,0 +1,37 @@
+import unittest
+from idlelib.Delegator import Delegator
+
+class DelegatorTest(unittest.TestCase):
+
+ def test_mydel(self):
+ # test a simple use scenario
+
+ # initialize
+ mydel = Delegator(int)
+ self.assertIs(mydel.delegate, int)
+ self.assertEqual(mydel._Delegator__cache, set())
+
+ # add an attribute:
+ self.assertRaises(AttributeError, mydel.__getattr__, 'xyz')
+ bl = mydel.bit_length
+ self.assertIs(bl, int.bit_length)
+ self.assertIs(mydel.__dict__['bit_length'], int.bit_length)
+ self.assertEqual(mydel._Delegator__cache, {'bit_length'})
+
+ # add a second attribute
+ mydel.numerator
+ self.assertEqual(mydel._Delegator__cache, {'bit_length', 'numerator'})
+
+ # delete the second (which, however, leaves it in the name cache)
+ del mydel.numerator
+ self.assertNotIn('numerator', mydel.__dict__)
+ self.assertIn('numerator', mydel._Delegator__cache)
+
+ # reset by calling .setdelegate, which calls .resetcache
+ mydel.setdelegate(float)
+ self.assertIs(mydel.delegate, float)
+ self.assertNotIn('bit_length', mydel.__dict__)
+ self.assertEqual(mydel._Delegator__cache, set())
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2, exit=2)
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/231c122b44b6
changeset: 84399:231c122b44b6
branch: 2.7
parent: 84392:a568a5426a16
user: Terry Jan Reedy <tjreedy(a)udel.edu>
date: Sun Jun 30 18:36:53 2013 -0400
summary:
Issue #18189: add test_delegator for Idle Delegator class.
Also change private dict used as a set to a set.
files:
Lib/idlelib/Delegator.py | 6 +-
Lib/idlelib/idle_test/test_delegator.py | 37 +++++++++++++
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -4,16 +4,16 @@
def __init__(self, delegate=None):
self.delegate = delegate
- self.__cache = {}
+ self.__cache = set()
def __getattr__(self, name):
attr = getattr(self.delegate, name) # May raise AttributeError
setattr(self, name, attr)
- self.__cache[name] = attr
+ self.__cache.add(name)
return attr
def resetcache(self):
- for key in self.__cache.keys():
+ for key in self.__cache:
try:
delattr(self, key)
except AttributeError:
diff --git a/Lib/idlelib/idle_test/test_delegator.py b/Lib/idlelib/idle_test/test_delegator.py
new file mode 100644
--- /dev/null
+++ b/Lib/idlelib/idle_test/test_delegator.py
@@ -0,0 +1,37 @@
+import unittest
+from idlelib.Delegator import Delegator
+
+class DelegatorTest(unittest.TestCase):
+
+ def test_mydel(self):
+ # test a simple use scenario
+
+ # initialize
+ mydel = Delegator(int)
+ self.assertIs(mydel.delegate, int)
+ self.assertEqual(mydel._Delegator__cache, set())
+
+ # add an attribute:
+ self.assertRaises(AttributeError, mydel.__getattr__, 'xyz')
+ bl = mydel.bit_length
+ self.assertIs(bl, int.bit_length)
+ self.assertIs(mydel.__dict__['bit_length'], int.bit_length)
+ self.assertEqual(mydel._Delegator__cache, {'bit_length'})
+
+ # add a second attribute
+ mydel.numerator
+ self.assertEqual(mydel._Delegator__cache, {'bit_length', 'numerator'})
+
+ # delete the second (which, however, leaves it in the name cache)
+ del mydel.numerator
+ self.assertNotIn('numerator', mydel.__dict__)
+ self.assertIn('numerator', mydel._Delegator__cache)
+
+ # reset by calling .setdelegate, which calls .resetcache
+ mydel.setdelegate(float)
+ self.assertIs(mydel.delegate, float)
+ self.assertNotIn('bit_length', mydel.__dict__)
+ self.assertEqual(mydel._Delegator__cache, set())
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2, exit=2)
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/ae69436eb7c2
changeset: 84398:ae69436eb7c2
parent: 84396:de73e7ffabb3
parent: 84397:c17fa2cbad43
user: Vinay Sajip <vinay_sajip(a)yahoo.co.uk>
date: Sun Jun 30 22:11:46 2013 +0100
summary:
Issue #18224: Updated test.
files:
Lib/test/test_venv.py | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -23,12 +23,10 @@
self.env_dir = os.path.realpath(tempfile.mkdtemp())
if os.name == 'nt':
self.bindir = 'Scripts'
- self.pydocname = 'pydoc.py'
self.lib = ('Lib',)
self.include = 'Include'
else:
self.bindir = 'bin'
- self.pydocname = 'pydoc'
self.lib = ('lib', 'python%s' % sys.version[:3])
self.include = 'include'
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ:
@@ -78,8 +76,6 @@
executable = sys.executable
path = os.path.dirname(executable)
self.assertIn('home = %s' % path, data)
- data = self.get_text_file_contents(self.bindir, self.pydocname)
- self.assertTrue(data.startswith('#!%s%s' % (self.env_dir, os.sep)))
fn = self.get_env_file(self.bindir, self.exe)
if not os.path.exists(fn): # diagnostics for Windows buildbot failures
bd = self.get_env_file(self.bindir)
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/c17fa2cbad43
changeset: 84397:c17fa2cbad43
branch: 3.3
parent: 84395:af837bf390d0
user: Vinay Sajip <vinay_sajip(a)yahoo.co.uk>
date: Sun Jun 30 22:11:10 2013 +0100
summary:
Issue #18224: Updated test.
files:
Lib/test/test_venv.py | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -23,12 +23,10 @@
self.env_dir = os.path.realpath(tempfile.mkdtemp())
if os.name == 'nt':
self.bindir = 'Scripts'
- self.pydocname = 'pydoc.py'
self.lib = ('Lib',)
self.include = 'Include'
else:
self.bindir = 'bin'
- self.pydocname = 'pydoc'
self.lib = ('lib', 'python%s' % sys.version[:3])
self.include = 'include'
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ:
@@ -78,8 +76,6 @@
executable = sys.executable
path = os.path.dirname(executable)
self.assertIn('home = %s' % path, data)
- data = self.get_text_file_contents(self.bindir, self.pydocname)
- self.assertTrue(data.startswith('#!%s%s' % (self.env_dir, os.sep)))
fn = self.get_env_file(self.bindir, self.exe)
if not os.path.exists(fn): # diagnostics for Windows buildbot failures
bd = self.get_env_file(self.bindir)
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/de73e7ffabb3
changeset: 84396:de73e7ffabb3
parent: 84394:6584e1ddc347
parent: 84395:af837bf390d0
user: Vinay Sajip <vinay_sajip(a)yahoo.co.uk>
date: Sun Jun 30 22:08:27 2013 +0100
summary:
Closes #18224: Removed pydoc script from created venv, as it causes problems on Windows and adds no value over and above python -m pydoc ...
files:
Lib/venv/scripts/nt/pydoc.py | 4 ----
Lib/venv/scripts/posix/pydoc | 5 -----
Misc/NEWS | 3 +++
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/Lib/venv/scripts/nt/pydoc.py b/Lib/venv/scripts/nt/pydoc.py
deleted file mode 100644
--- a/Lib/venv/scripts/nt/pydoc.py
+++ /dev/null
@@ -1,4 +0,0 @@
-#!__VENV_PYTHON__
-if __name__ == '__main__':
- import sys, pydoc
- sys.exit(pydoc.cli())
diff --git a/Lib/venv/scripts/posix/pydoc b/Lib/venv/scripts/posix/pydoc
deleted file mode 100755
--- a/Lib/venv/scripts/posix/pydoc
+++ /dev/null
@@ -1,5 +0,0 @@
-#!__VENV_PYTHON__
-if __name__ == '__main__':
- import sys, pydoc
- sys.exit(pydoc.cli())
-
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -135,6 +135,9 @@
Library
-------
+- Issue #18224: Removed pydoc script from created venv, as it causes problems
+ on Windows and adds no value over and above python -m pydoc ...
+
- Issue #18155: The csv module now correctly handles csv files that use
a delimter character that has a special meaning in regexes, instead of
throwing an exception.
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/af837bf390d0
changeset: 84395:af837bf390d0
branch: 3.3
parent: 84393:9d65716367c1
user: Vinay Sajip <vinay_sajip(a)yahoo.co.uk>
date: Sun Jun 30 22:06:52 2013 +0100
summary:
Issue #18224: Removed pydoc script from created venv, as it causes problems on Windows and adds no value over and above python -m pydoc ...
files:
Lib/venv/scripts/nt/pydoc.py | 4 ----
Lib/venv/scripts/posix/pydoc | 5 -----
Misc/NEWS | 3 +++
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/Lib/venv/scripts/nt/pydoc.py b/Lib/venv/scripts/nt/pydoc.py
deleted file mode 100644
--- a/Lib/venv/scripts/nt/pydoc.py
+++ /dev/null
@@ -1,4 +0,0 @@
-#!__VENV_PYTHON__
-if __name__ == '__main__':
- import sys, pydoc
- sys.exit(pydoc.cli())
diff --git a/Lib/venv/scripts/posix/pydoc b/Lib/venv/scripts/posix/pydoc
deleted file mode 100755
--- a/Lib/venv/scripts/posix/pydoc
+++ /dev/null
@@ -1,5 +0,0 @@
-#!__VENV_PYTHON__
-if __name__ == '__main__':
- import sys, pydoc
- sys.exit(pydoc.cli())
-
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -38,6 +38,9 @@
Library
-------
+- Issue #18224: Removed pydoc script from created venv, as it causes problems
+ on Windows and adds no value over and above python -m pydoc ...
+
- Issue #18155: The csv module now correctly handles csv files that use
a delimter character that has a special meaning in regexes, instead of
throwing an exception.
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/6584e1ddc347
changeset: 84394:6584e1ddc347
parent: 84390:29e7f6a2dc0d
parent: 84393:9d65716367c1
user: Terry Jan Reedy <tjreedy(a)udel.edu>
date: Sun Jun 30 16:52:40 2013 -0400
summary:
Merge with 3.3
files:
Lib/idlelib/Delegator.py | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -20,14 +20,6 @@
pass
self.__cache.clear()
- def cachereport(self):
- keys = list(self.__cache.keys())
- keys.sort()
- print(keys)
-
def setdelegate(self, delegate):
self.resetcache()
self.delegate = delegate
-
- def getdelegate(self):
- return self.delegate
--
Repository URL: http://hg.python.org/cpython
http://hg.python.org/cpython/rev/9d65716367c1
changeset: 84393:9d65716367c1
branch: 3.3
parent: 84389:19bc00996e74
user: Terry Jan Reedy <tjreedy(a)udel.edu>
date: Sun Jun 30 16:52:19 2013 -0400
summary:
Issue 18189: remove unused methods in idlelib.Delegator.Delegator.
Idle code already uses x.delegate instead of x.getdelegate().
The printed report must have been for testing.
files:
Lib/idlelib/Delegator.py | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -20,14 +20,6 @@
pass
self.__cache.clear()
- def cachereport(self):
- keys = list(self.__cache.keys())
- keys.sort()
- print(keys)
-
def setdelegate(self, delegate):
self.resetcache()
self.delegate = delegate
-
- def getdelegate(self):
- return self.delegate
--
Repository URL: http://hg.python.org/cpython