Comments (14)
@fernandez85 i think, the fix is simple.
array_tobytes = getattr(array.array, "tobytes", array.array.tostring)
to:
array_tobytes = getattr(array.array, "tostring", array.array.tobytes)
from intelhex.
Okay folks, you should see a new release on pypi. pip seems to have found it:
$ pip search intelhex
intelhex (2.3.0) - Python library for Intel HEX files manipulations
...
readthedocs.io has not been updated yet, but that wasn't a priority :)
from intelhex.
Do you know why even this issue exist?
Because in this code:
getattr(array.array, "tobytes", array.array.tostring)
tostring is not available in 3.9, even if tobytes is present, because default argument is processed anyway and it simply doesn't exist, that is why exception was thrown
the same will be (but opposite) with:
array_tobytes = getattr(array.array, "tostring", array.array.tobytes)
Is this really hard to understand?
In my solution only one attribute is processed, because of if statement
from intelhex.
because defualt argument is process anyway
Aha... Thanks, now it is cleare.
from intelhex.
Update: We've figured out PyPi, that isn't a showstopper anymore :)
from intelhex.
Can confirm this issue on Python 3.9.
Traceback if necessary:
Traceback (most recent call last):
File "/Users/ashley/Library/Python/3.9/bin/solo", line 5, in <module>
from solo.cli import solo_cli
File "/Users/ashley/Library/Python/3.9/lib/python/site-packages/solo/__init__.py", line 15, in <module>
from . import client, commands, dfu, helpers, operations
File "/Users/ashley/Library/Python/3.9/lib/python/site-packages/solo/client.py", line 27, in <module>
from intelhex import IntelHex
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/intelhex/__init__.py", line 44, in <module>
from intelhex.compat import (
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/intelhex/compat.py", line 60, in <module>
array_tobytes = getattr(array.array, "tobytes", array.array.tostring)
AttributeError: type object 'array.array' has no attribute 'tostring'
from intelhex.
tobytes was introduced in ver 3.2, and since then tostring is deprecated alias for tobytes
current implementation isn't ready for situation when it's completely removed, and that what happened in ver 3.9
from intelhex.
I was thinking about this at first time, but then same problem will be with python ver 3.0.x, and 3.1.x. I know there shouldn't be many users of these versions, but best way is to make it right :)
This should do the trick (in that exact place):
array_tobytes = array.array.tobytes if sys.version_info[1] >= 2 else array.array.tostring
or use hasattr
from intelhex.
getattr(array.array, "tostring", array.array.tobytes)
array.array.tobytes if sys.version_info[1] >= 2 else array.array.tostring
IIt does't matter, the result is the same. But for me is interesting:
@fernandez85 I was thinking about this at first time, but then same problem will be with python ver 3.0.x, and 3.1.x.
Why? All python < 3.9 has "tostring", for python >=3.9 it will use the default as "tobytes".
from intelhex.
Thank you @The-42 for merging the PR that fixes this.
Is there any change a new release could be cut and the PyPi package updated as well as most folks just pull intelhex as a dependency through pip?
Thanks in advance.
from intelhex.
getattr(array.array, "tostring", array.array.tobytes)
array.array.tobytes if sys.version_info[1] >= 2 else array.array.tostring
IIt does't matter, the result is the same. But for me is interesting:
It does matter, because it isn't the same. It wouldn't matter for >=3.2 only, but then we wouldn't need getattr anymore
@fernandez85 I was thinking about this at first time, but then same problem will be with python ver 3.0.x, and 3.1.x.
Why? All python < 3.9 has "tostring", for python >=3.9 it will use the default as "tobytes".
But not all has tobytes - it was introduced in ver 3.2
Your proposal simply causes the same problem as it was at first place,... but in opposite, only for those that still uses python 3.0-3.1
from intelhex.
But not all has tobytes - it was introduced in ver 3.2
And what? It has tostring and it will be used, othervise tobyte will be used
If the named attribute does not exist, default is returned
getattr(object, name[, default])
Return the value of the named attribute of object. name must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar. If the named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.
from intelhex.
Thank you @The-42 for merging the PR that fixes this.
Is there any change a new release could be cut and the PyPi package updated as well as most folks just pull intelhex as a dependency through pip?
Thanks in advance.
I'll see to packing a release soon, still need to check on a couple issues though. Uploading to PyPi is currently out of my hands as @bialix is the Pypi maintainer for this package.
from intelhex.
Thank you @The-42 for the expedited release :-)
from intelhex.
Related Issues (20)
- Can you add hex file support for TI C28x DSP? HOT 7
- TypeError while loading from TemporaryFile (Python 3) HOT 2
- hexdiff.py not working on Ubuntu 19.10 HOT 7
- The binary limitation of bin2hex is 4Kbytes. HOT 3
- Option to insert 'Extended Segment Address' record type instead of 'Extended Linear Address' HOT 6
- Starting Address record line is always the first line, but in original file it was last line HOT 11
- Merge fails on two IntelHex16bit files... HOT 1
- A [0:0] slice will return the entire contents, when it should return a empty object HOT 1
- Array attribute HOT 2
- list(ih) causes the Python interpreter to hang up HOT 1
- Is it possible to get rid of those padding byte in list(ih)? HOT 8
- padding byte not retained in slices HOT 1
- Check two IntelHex objects equality HOT 7
- intelhex hangs on using `in` operator HOT 2
- CS:IP entry point calculation seems to be incorrect HOT 2
- Swapping of bytes HOT 2
- bin2hex.py adds extra random byte HOT 2
- Search doesn't appear to work on the readthedocs site.
- Documentation for hex2bin function is not generated.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intelhex.