Closed MrBenGriffin closed 3 years ago
The U
parameter has been deprecated since Python 3 and universal newlines are enabled by default so it shouldn't be needed: https://docs.python.org/3/library/functions.html#open
There is an additional mode character permitted, 'U', which no longer has any effect, and is considered deprecated. It previously enabled universal newlines in text mode, which became the default behaviour in Python 3.0. Refer to the documentation of the newline parameter for further details.
Doesn't mean there is no bug here though... because that only works for text mode and the files are read in binary mode ;)
I've fixed it for the pure python based parsing and added tests for it. Now the speedups module needs support too...
I believe I've fixed it. Can you try the develop branch?
Yeah, my 'U' suggestion was wrong on this - but the problem was there.. (otherwise I wouldn't have found it!)
I will indeed test as soon as I have some time ;-D
Hi yeah, that works now - it still fails for 'Mac OS 9' (CR) line endings - the error is as follows. However, for LF and CRLF it's working great - thanks!
The following error appears now only for CR line endings I think the exception sprogging off another exception could probably be handled a bit more gracefully.
exception (0, 'Line longer than 8192, probably non-ascii')
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stl/stl.py", line 71, in load
name, data = cls._load_ascii(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stl/stl.py", line 233, in _load_ascii
return _speedups.ascii_read(fh, header)
File "stl/_speedups.pyx", line 121, in stl._speedups.ascii_read
File "stl/_speedups.pyx", line 72, in stl._speedups.readline
RuntimeError: (0, 'Line longer than 8192, probably non-ascii')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stl/stl.py", line 374, in from_file
name, data = cls.load(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stl/stl.py", line 91, in load
name, data = cls._load_binary(fh, header,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stl/stl.py", line 111, in _load_binary
assert count < MAX_COUNT, ('File too large, got %d triangles which '
AssertionError: File too large, got 808464441 triangles which exceeds the maximum of 100000000
The last Mac OS 9 release is about 20 years old, I don't think that any machine capable of running that is using 3D software :P
The last Mac OS 9 release is about 20 years old, I don't think that any machine capable of running that is using 3D software :P
I accept that! It's just sometimes (rarely) people mess up their line returns - but as far as I'm concerned it's looking good, and feel free to close it.
Great, thanks for the bug report :)
mesh.Mesh.from_file() only works with CRLF line returns. While this may be ostensibly accurate, the error message is not correct, and it is trivial (within python) for the line return style being used in a file.
print open('myfile.txt', 'U').read()