demntor / pymodbus

Modbus Python release (tools included)
0 stars 0 forks source link

Invalid syntax errors under python versions prior to 2.5 #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1.  Attempt to install under Python versions prior to 2.5.
2.  Several syntax errors will occur as per the example below.
3.  Running "test" or any other options will also produce similar errors.

What is the expected output? What do you see instead?

Here's is one example of the error:
byte-compiling build/bdist.linux-i686/egg/pymodbus/other_message.py to 
other_message.pyc
  File "build/bdist.linux-i686/egg/pymodbus/other_message.py", line 183
    ready = ModbusStatus.Ready if self.status else ModbusStatus.Waiting
                                ^
SyntaxError: invalid syntax

Here is the complete list of all files affected during installation:
build/bdist.linux-i686/egg/pymodbus/other_message.py
build/bdist.linux-i686/egg/pymodbus/register_read_message.py
build/bdist.linux-i686/egg/pymodbus/bit_write_message.py
build/bdist.linux-i686/egg/pymodbus/transaction.py

What version of the product are you using? On what operating system?

pymodbus-0.9.0
Redhat EL5.6
Python 2.4.3

Please provide any additional information below.

As per the Python documentation, the syntax used is only valid as of Python 
2.5.  However, your documentation claims that pymodbus should work under 2.3 or 
later.  Here is a link to the appropriate documentation:
http://docs.python.org/release/3.0.1/whatsnew/2.5.html#pep-308-conditional-expre
ssions

Original issue reported on code.google.com by rubbersi...@gmail.com on 14 Jun 2011 at 3:50

GoogleCodeExporter commented 8 years ago
I was able to patch together a "working" version under my installation of 
Redhat EL5.6 x64, which I will attach for reference.  I did have to change a 
few other things that were not working, such as the fact that True and False 
are not reserved words in the older version of Python.  I was however able to 
get it to pass all of "setup.py test" successfully.  If you think these changes 
should work properly, then I may just use my modifications for now.

Thanks,
Kelly Shutt

Original comment by rubbersi...@gmail.com on 14 Jun 2011 at 6:50

Attachments:

GoogleCodeExporter commented 8 years ago
Ah you are right, I added a few >= python 2.5 features without bumping that 
least supported version.  Well I can fix the True/False issue by just defining 
them if they don't exist.

As for the ternary, I do like how it looks.  However, if enough people are 
sitting on an old version of python (< 2.5), I would hate to block their usage 
for 13 lines.  I looked through a diff of your code and trunk and that was all 
I found (aside from some spacing changes).

Original comment by Bashw...@gmail.com on 15 Jun 2011 at 4:41

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r151.

Original comment by Bashw...@gmail.com on 15 Jun 2011 at 4:43

GoogleCodeExporter commented 8 years ago
Well, anyone that's running Redhat 5 is going to be limited to Python 2.4.  
They didn't update the major version until Redhat 6, in which case they only 
upgraded to Python 2.6.  Redhat is very slow to adopt new major versions, as 
they spend a lot of time testing, etc. to make sure they're providing a rock 
solid enterprise product.

BTW, I have a new copy for you in which I've implemented a few things that were 
not there yet.  Such as allowing use of the diagnostic messages through the 
Client interface.  Do you want me to post it here, or send it somewhere else?

I'm working on building a better replacement for a custom built Modbus driver 
that we're using at present, which was written several years ago now, and would 
like to use your libraries at its base.  I may be making more additions to your 
code in the coming weeks.

Peace,
Kelly

Original comment by rubbersi...@gmail.com on 17 Jun 2011 at 5:43

GoogleCodeExporter commented 8 years ago
I'm stuck on a TS-7260 
(http://www.embeddedarm.com/products/board-detail.php?product=TS-7260), which 
runs linux-2.4 and debian sarge.  I've upgraded debian to etch, where the 
default python is 2.4, but I cannot upgrade beyond etch since debian migrated 
to the new ARM ABI (armel) with the lenny release and a cross-architecture 
upgrade is nontrivial.  I might attempt it were I more proficient and confident 
with embedded systems, but I am not.  I'm only an undergraduate pretending to 
be an engineer as I work for an astroparticle physics experiment on autonomous 
calibration systems.

Here's my patch anyway:

Original comment by jfind...@gmail.com on 11 Aug 2011 at 8:08

Attachments:

GoogleCodeExporter commented 8 years ago
Fair enough. I would rather it work for everyone than be pretty. I will add the 
change when I get back from my trip at the end of August. Until then, everyone 
simple use this patch and post any other version issues you have here.

Original comment by Bashw...@gmail.com on 11 Aug 2011 at 9:57

GoogleCodeExporter commented 8 years ago

Original comment by Bashw...@gmail.com on 18 Aug 2011 at 5:52

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r157.

Original comment by Bashw...@gmail.com on 31 Aug 2011 at 2:32