Hi everybody, During the porting of Zope2 to Python2.6, I am stuck with a syntax error in the module AccessControl, which is given below. def reorder(s, with=None, without=()): ^ SyntaxError: invalid syntax in line 56 of /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py. The same code when run in python2.4 and python2.5 didn't give any syntax errors. Can anybody suggest the reason for this syntax error in python2.6.
Bristow Thankachan wrote:
Hi everybody,
During the porting of Zope2 to Python2.6, I am stuck with a syntax error in the module AccessControl, which is given below.
def reorder(s, with=None, without=()): ^ SyntaxError: invalid syntax
in line 56 of /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py. The same code when run in python2.4 and python2.5 didn't give any syntax errors. Can anybody suggest the reason for this syntax error in python2.6.
I'd say, "with" is now a keyword. http://docs.python.org/ref/keywords.html btw, shouldn't this already give a warning in 2.5? Cheers Tino
Thank you for the quick response. I made the change and got the syntax error corrected. with regards Bristow. On Mon, Jul 21, 2008 at 4:57 PM, Tino Wildenhain <tino@wildenhain.de> wrote:
Bristow Thankachan wrote:
Hi everybody,
During the porting of Zope2 to Python2.6, I am stuck with a syntax error in the module AccessControl, which is given below.
def reorder(s, with=None, without=()): ^ SyntaxError: invalid syntax
in line 56 of /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py. The same code when run in python2.4 and python2.5 didn't give any syntax errors. Can anybody suggest the reason for this syntax error in python2.6.
I'd say, "with" is now a keyword.
http://docs.python.org/ref/keywords.html
btw, shouldn't this already give a warning in 2.5?
Cheers Tino
How did you change it ? If you change "with" there, it may break backward compatibility, I am afraid. Regards, Baiju M Bristow Thankachan wrote:
Thank you for the quick response. I made the change and got the syntax error corrected.
with regards
Bristow.
On Mon, Jul 21, 2008 at 4:57 PM, Tino Wildenhain <tino@wildenhain.de <mailto:tino@wildenhain.de>> wrote:
Bristow Thankachan wrote:
Hi everybody,
During the porting of Zope2 to Python2.6, I am stuck with a syntax error in the module AccessControl, which is given below.
def reorder(s, with=None, without=()): ^ SyntaxError: invalid syntax
in line 56 of /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py. The same code when run in python2.4 and python2.5 didn't give any syntax errors. Can anybody suggest the reason for this syntax error in python2.6.
I'd say, "with" is now a keyword.
http://docs.python.org/ref/keywords.html
btw, shouldn't this already give a warning in 2.5?
Cheers Tino
------------------------------------------------------------------------
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Hi, Bristow Thankachan wrote: ...
def reorder(s, with=None, without=()): ^ SyntaxError: invalid syntax
in line 56 of /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py. The same code when run in python2.4 and python2.5 didn't give any syntax errors. Can anybody suggest the reason for this syntax error in python2.6.
I'd say, "with" is now a keyword.
http://docs.python.org/ref/keywords.html
btw, shouldn't this already give a warning in 2.5?
Actually it does: python2.5 Python 2.5.2 (r252:60911, Apr 17 2008, 13:15:05) [GCC 4.2.3 (Debian 4.2.3-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
def foo(with=5): <stdin>:1: Warning: 'with' will become a reserved keyword in Python 2.6 ... pass ...
So while I'm generally happy with getting zope and python developement better in sync it seems we have been too fast here since I believe python2.5 migration is actually still in process and now you are heading for 2.6? Doing it one after the other should already ruled out such problems. I wonder what can of worms is waiting in the restricted python area. Tino
On Monday 21 July 2008, Tino Wildenhain wrote:
btw, shouldn't this already give a warning in 2.5?
It does. I see it. Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. "Zope Stephan Richter"
hi all, I changed the attribute 'with' in /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py to 'wit' and I ran the tests in python2.4 and I got the following result. Running tests at level 1 Running unit tests: Running: Ran 285 tests with 0 failures and 0 errors in 6.587 seconds. Running Testing.ZopeTestCase.layer.ZopeLite tests: Set up Testing.ZopeTestCase.layer.ZopeLite in 0.000 seconds. Running: Ran 1 tests with 0 failures and 0 errors in 0.064 seconds. Tearing down left over layers: Tear down Testing.ZopeTestCase.layer.ZopeLite in 0.000 seconds. Total: 286 tests, 0 failures, 0 errors in 1.044 seconds. Can anybody tell me whether this implies it is backward compatible in python2.4? with regards Bristow On Mon, Jul 21, 2008 at 4:43 PM, Bristow Thankachan < bristow.thankachan@gmail.com> wrote:
Hi everybody,
During the porting of Zope2 to Python2.6, I am stuck with a syntax error in the module AccessControl, which is given below.
def reorder(s, with=None, without=()): ^ SyntaxError: invalid syntax
in line 56 of /home/zope/ztrunk26/lib/python/RestrictedPython/Utilities.py. The same code when run in python2.4 and python2.5 didn't give any syntax errors. Can anybody suggest the reason for this syntax error in python2.6.
On Mon, Jul 21, 2008 at 14:09, Bristow Thankachan <bristow.thankachan@gmail.com> wrote:
Can anybody tell me whether this implies it is backward compatible in python2.4?
If you change the API it isn't backwards compatible. The question is if this is a problem or not, if anything outside Zope itself is using this call, which is hard to say. Options here are 1. Deprecating the "with" parameter for "with_" and supporting both in 2.12 but not supporting Python2.6. 2. Using **kw in the argument and looking for noth "with" and "with_", that way, which will be backwards compatible. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Malthe Borch wrote:
Lennart Regebro wrote:
2. Using **kw in the argument and looking for noth "with" and "with_", that way, which will be backwards compatible.
+1
The implementation of this function is already so obscure that using keywords should not be a problem. OTOH, the reorder function in RestrictedPython was ported from a version originally designed for doing ordered select lists in DTML: $ cvs log lib/python/DocumentTemplate/DT_Util.py ... revision 1.52 date: 1999/03/22 17:28:37; author: jim; state: Exp; lines: +31 -2 Added a new "builtin" function reorder: reorder(s, [with, without]]) -- Reorder the items in s according to the order given in with and with items mentioned in without removed. Items from s not mentioned in with are removed. s, with, and without are all either sequences if strings or sequences of key-value tuples, with ordering done on the keys. This function is useful for constructing ordered select lists. ... The only use of the method in Zope's own DTML is in the addZClass.dtml template. I'm willing to bet that *nobody* who is still using it would be surprised if they had to recode it when upgrading to a recent Zope, so maybe we can just change the trunk without worrying about it. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIhJ7A+gerLs4ltQ4RAk6lAJ0T6JJC/4nr6kA7jzSQqKSNZUGP7ACeIO2R H7k2D46BKQ+DL0girE8EGOk= =HLxo -----END PGP SIGNATURE-----
On Mon, Jul 21, 2008 at 16:35, Tres Seaver <tseaver@palladion.com> wrote:
The only use of the method in Zope's own DTML is in the addZClass.dtml template. I'm willing to bet that *nobody* who is still using it would be surprised if they had to recode it when upgrading to a recent Zope, so maybe we can just change the trunk without worrying about it.
OK, cool. Changing from "with" to "with_" is probably a good solution then. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64
participants (7)
-
Baiju M -
Bristow Thankachan -
Lennart Regebro -
Malthe Borch -
Stephan Richter -
Tino Wildenhain -
Tres Seaver