473,568 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Compiler, ast and forwards/backwards compatibility

On Tue, Oct 7, 2008 at 5:39 PM, Terry Reedy <tj*****@udel.e duwrote:
Orestis Markou wrote:
>>
Hello,

I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a
static analysis/intellisense provider for Python. I am targeting
Python 2.4 code so I'm using the compiler package.

I've been toying around yesterday with the ast module in Python 2.6
and it seems much more cleaner. One thing I don't understand is how
should one handle backwards and forwards compatibility.

My impression is that the 2.6 ast package is quite different from the 2.4
compiler package, but I have not looked at it (in its 3.0 version) yet. If
the 2.4 code you are analyzing is syntactically and sematically valid as 2.6
code, which I believe is usual, then of course there is no problem. If it
is not, then I would not be sure.
The ast module is indeed very different from the compiler package, as
it depends on the exact grammar definition that the interpreter is
using, rather a re-implementation (which I understand the compiler.ast
is).

My confusion starts with the fact that I'm not sure if all Python 2.4
code is going to be syntactically valid 2.6 code. I guess 2.3 is valid
2.4 is valid 2.5, which should be valid 2.6 (but not valid 3.0) - I
think it's the lockstep of 2.6 and 3.0 that's misleading me...
>
>I guess that Python 2.6 can target Python 2.3-6, and with specific
compiler flags it can also target 3.0, so it seems that the correct
thing to do is to use that.

If you want to target 2.3 to 3.0, 2.6 is the only option as far as I know.
I expect you will want to run your code through 2to3 (still being improved)
and run under 3.0 to properly handle 3.0 code.
That sounds correct. It's annoying that I have to require Python 2.6
for this - I guess that since the compiler module is there in 2.6 I'm
not compelled to use ast until I want to run under 3.0...
>
Maybe someone else can give a better answer.

tjr

--
http://mail.python.org/mailman/listinfo/python-list


--
or*****@orestis .gr
http://orestis.gr
Oct 7 '08 #1
1 1856
My confusion starts with the fact that I'm not sure if all Python 2.4
code is going to be syntactically valid 2.6 code.
That's not so much a matter of confusion, but of careful research.

I *think* all code that is syntactically correct in 2.4 is also
syntactically correct in 2.6 - but only because

raise "Hello"

is still syntactically correct in 2.6 - it's a TypeError, not a
SyntaxError. The other case would be assignment to None, but that
was banned in 2.4 already.
I guess 2.3 is valid
2.4 is valid 2.5
I think not so: assignment to None got disallowed, syntactically
(can't test 2.3, at the moment).

Regards,
Martin
Oct 8 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1777
by: Jason Mobarak | last post by:
Greetings! Say that it's desirable to provide backwards compatibility for methods of an object, consider the case where... class Foo: def bar (self, a, b): pass ....is a defined class that can be serialized and later be deserialized.
0
1343
by: flat_ross | last post by:
If there was one thing nice about "Binary Compatibility" in VB6, it would tell you at compile time that you changed your public interface. I am looking for the same functionality in .NET. I know all the underlying stuff is different. But at the end of the day, I want to be told if the changes I made to my public interface are backwards...
7
2142
by: Sonny | last post by:
I need to port a library that is written entirely in C to C++. The library is supported on quite a few platforms (windows, Solaris, Linux, AIX, HP-UX, OSX, etc...) and there's quite an existing customer base that uses it. I need to maintain backwards compatibility such that existing users won't have to do anything to their existing...
19
2830
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type > >pointer-to-array-of-size-N-of-type-T (which is fine) and not having type > >array-of-size-N-of-type-T (with some exceptions, which is curious). > > So far > >the consensus seems to...
70
3992
by: py | last post by:
I have function which takes an argument. My code needs that argument to be an iterable (something i can loop over)...so I dont care if its a list, tuple, etc. So I need a way to make sure that the argument is an iterable before using it. I know I could do... def foo(inputVal): if isinstance(inputVal, (list, tuple)): for val in inputVal:...
150
6438
by: tony | last post by:
If you have any PHP scripts which will not work in the current releases due to breaks in backwards compatibility then take a look at http://www.tonymarston.net/php-mysql/bc-is-everything.html and see if you agree with my opinion or not. Tony Marston http://www.tonymarston.net
1
2206
by: Orestis Markou | last post by:
Hello, I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a static analysis/intellisense provider for Python. I am targeting Python 2.4 code so I'm using the compiler package. I've been toying around yesterday with the ast module in Python 2.6 and it seems much more cleaner. One thing I don't understand is how should one...
0
168
by: Terry Reedy | last post by:
Orestis Markou wrote: The lockstep stuff is either new stuff which does not (at least, is intended not to) affect old code, or changes that you have to request via __future__ imports. Much 1.5 code runs fine on 2.6. I was careful to differentiate between syntax and semantics. I do not know of any 2.4 syntax that would not work in 2.6. ...
18
2015
by: MyWaterloo | last post by:
I quickly put this code together to test if it would disable some of my functions OnChange when my text box (purchase order number) is empty...and if it would enable those functions when I added data to my field. The funny thing is that if you read the code it actually runs in reverse! When my field is null it is suppose to disable...instead it...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.