473,503 Members | 1,787 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.eduwrote:
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 1844
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
1765
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...
0
1336
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...
7
2139
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...
19
2821
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 >...
70
3970
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...
150
6320
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...
1
2200
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. ...
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...
18
2003
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...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
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...
1
6982
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...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4667
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...
0
3161
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...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.