Log message for revision 102308:
  - fixed test_filepath for Python 2.6
  - fixed the issue shown by test_filepath (changed the initial function 
__name__ to 'script')
  - adjusted test__name__

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  UU  Zope/branches/2.12/src/Products/PythonScripts/PythonScript.py
  UU  Zope/branches/2.12/src/Products/PythonScripts/tests/testPythonScript.py
  U   Zope/branches/2.12/src/Products/PythonScripts/tests/tscripts/filepath.ps

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst  2009-07-26 12:45:25 UTC (rev 102307)
+++ Zope/branches/2.12/doc/CHANGES.rst  2009-07-26 13:08:59 UTC (rev 102308)
@@ -20,6 +20,8 @@
 Bugs Fixed
 ++++++++++
 
+- PythonScript: Fixed small Python 2.6 compatibility issue.
+
 - mkzopeinstance: Made instance scripts more suitable for egg based installs.
   If you are using a customized skel, it has to be updated.
 

Modified: Zope/branches/2.12/src/Products/PythonScripts/PythonScript.py
===================================================================
--- Zope/branches/2.12/src/Products/PythonScripts/PythonScript.py       
2009-07-26 12:45:25 UTC (rev 102307)
+++ Zope/branches/2.12/src/Products/PythonScripts/PythonScript.py       
2009-07-26 13:08:59 UTC (rev 102308)
@@ -7,16 +7,16 @@
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
+# FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-
 """Python Scripts Product
 
 This product provides support for Script objects containing restricted
 Python code.
+
+$Id$
 """
-__version__='$Revision: 1.56 $'[11:-2]
 
 from logging import getLogger
 import marshal
@@ -273,7 +273,14 @@
         g = get_safe_globals()
         g['_getattr_'] = guarded_getattr
         g['__debug__'] = __debug__
-        g['__name__'] = None
+        # it doesn't really matter what __name__ is, *but*
+        # - we need a __name__
+        #   (see testPythonScript.TestPythonScriptGlobals.test__name__)
+        # - it should not contain a period, so we can't use the id
+        #   (see https://bugs.launchpad.net/zope2/+bug/142731/comments/4)
+        # - with Python 2.6 it should not be None
+        #   (see testPythonScript.TestPythonScriptGlobals.test_filepath)
+        g['__name__'] = 'script'
 
         l = {}
         exec code in g, l


Property changes on: 
Zope/branches/2.12/src/Products/PythonScripts/PythonScript.py
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.56
Added: svn:keywords
   + Id

Modified: 
Zope/branches/2.12/src/Products/PythonScripts/tests/testPythonScript.py
===================================================================
--- Zope/branches/2.12/src/Products/PythonScripts/tests/testPythonScript.py     
2009-07-26 12:45:25 UTC (rev 102307)
+++ Zope/branches/2.12/src/Products/PythonScripts/tests/testPythonScript.py     
2009-07-26 13:08:59 UTC (rev 102308)
@@ -10,7 +10,7 @@
 # FOR A PARTICULAR PURPOSE
 #
 ##############################################################################
-import os, sys, unittest, warnings
+import os, unittest, warnings
 
 from Products.PythonScripts.PythonScript import PythonScript
 from AccessControl.SecurityManagement import newSecurityManager
@@ -295,22 +295,25 @@
 
     def test__name__(self):
         f = self._filePS('class.__name__')
-        self.assertEqual(f(), ("'foo'>", "'string'"))
+        self.assertEqual(f(), ("'script.foo'>", "'string'"))
 
-    if sys.version_info < (2, 6):
-        def test_filepath(self):
-            # This test is meant to raise a deprecation warning.
-            # It used to fail mysteriously instead.
+    def test_filepath(self):
+        # This test is meant to raise a deprecation warning.
+        # It used to fail mysteriously instead.
+        def warnMe(message):
+            warnings.warn(message, stacklevel=2)
+
+        try:
+            f = self._filePS('filepath')
             self._trap_warning_output()
-            f = self._filePS('filepath')
-            self.assertEqual(f(), [0])
+            results = f._exec({'container': warnMe}, (), {})
             self._free_warning_output()
-    else:
-        def test_filepath(self):
-            # On Python 2.6, this now raises a TypeError.
-            f = self._filePS('filepath')
-            self.assertRaises(TypeError, f)
+            warning = self._our_stderr_stream.getvalue()
+            self.failUnless('UserWarning: foo' in warning)
+        except TypeError, e:
+            self.fail(e)
 
+
 class PythonScriptInterfaceConformanceTests(unittest.TestCase):
 
     def test_class_conforms_to_IWriteLock(self):


Property changes on: 
Zope/branches/2.12/src/Products/PythonScripts/tests/testPythonScript.py
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
   - 1.16
Added: svn:keywords
   + Id

Modified: 
Zope/branches/2.12/src/Products/PythonScripts/tests/tscripts/filepath.ps
===================================================================
--- Zope/branches/2.12/src/Products/PythonScripts/tests/tscripts/filepath.ps    
2009-07-26 12:45:25 UTC (rev 102307)
+++ Zope/branches/2.12/src/Products/PythonScripts/tests/tscripts/filepath.ps    
2009-07-26 13:08:59 UTC (rev 102308)
@@ -1,2 +1,2 @@
-return range(1.0)
+return container('foo')
 # This test is meant to raise a deprecation warning.

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to