Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntegerAccuracyLossError on i586 #33

Closed
jayvdb opened this issue Feb 8, 2019 · 8 comments
Closed

IntegerAccuracyLossError on i586 #33

jayvdb opened this issue Feb 8, 2019 · 8 comments

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Feb 8, 2019

======================================================================
[   68s] ERROR: test_bug_fixes.test_issue_30
[   68s] ----------------------------------------------------------------------
[   68s] Traceback (most recent call last):
[   68s]   File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
[   68s]     self.test(*self.arg)
[   68s]   File "/home/abuild/rpmbuild/BUILD/pyexcel-ods-0.5.4/tests/test_bug_fixes.py", line 149, in test_issue_30
[   68s]     sheet.save_as(test_file)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel/internal/meta.py", line 266, in save_as
[   68s]     return save_sheet(self, file_name=filename, **keywords)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel/internal/core.py", line 43, in save_sheet
[   68s]     return _save_any(a_source, sheet)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel/internal/core.py", line 55, in _save_any
[   68s]     a_source.write_data(instance)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel/plugins/sources/file_output.py", line 31, in write_data
[   68s]     self._file_name, sheet, **self._keywords
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel/plugins/renderers/excel.py", line 27, in render_sheet_to_file
[   68s]     save_data(file_name, data, **keywords)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel_io/io.py", line 127, in save_data
[   68s]     **keywords
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel_io/io.py", line 144, in store_data
[   68s]     writer.write(data)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel_io/book.py", line 220, in write
[   68s]     sheet_writer.write_array(incoming_dict[sheet_name])
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel_io/sheet.py", line 174, in write_array
[   68s]     self.write_row(row)
[   68s]   File "/home/abuild/rpmbuild/BUILD/pyexcel-ods-0.5.4/pyexcel_ods/odsw.py", line 70, in write_row
[   68s]     self.write_cell(row, cell)
[   68s]   File "/home/abuild/rpmbuild/BUILD/pyexcel-ods-0.5.4/pyexcel_ods/odsw.py", line 53, in write_cell
[   68s]     cell = converter_func(cell)
[   68s]   File "/usr/lib/python2.7/site-packages/pyexcel_io/service.py", line 197, in throw_exception
[   68s]     raise exceptions.IntegerAccuracyLossError("%s is too big" % value)
[   68s] IntegerAccuracyLossError: 999999999999999 is too big
[   68s] In order to keep its accuracy, please save as string. Then convert to int, long or float after the value will be read back

https://build.opensuse.org/package/live_build_log/home:jayvdb:pyexcel/python-pyexcel-ods/openSUSE_Tumbleweed/i586

@chfw
Copy link
Member

chfw commented Mar 16, 2019

related to #30

chfw added a commit to pyexcel/pyexcel-io that referenced this issue Mar 16, 2019
@chfw
Copy link
Member

chfw commented Mar 16, 2019

please try pyexcel-io v0.5.15

@chfw chfw closed this as completed Mar 16, 2019
@jayvdb
Copy link
Contributor Author

jayvdb commented Mar 17, 2019

This is still not working on Python 2 i586. It is ok on Python 3.

See failure log on https://build.opensuse.org/package/show/home:jayvdb:pyexcel/python-pyexcel-ods

You can log into opensuse and branch that package to upload and test a new sdist on i586 hardware, or travis can also do i586 jobs by using a docker image. Examples at travis-ci/travis-ci#5770

@chfw chfw reopened this Mar 17, 2019
@chfw
Copy link
Member

chfw commented Mar 17, 2019

My bad.

if PY2:
    ODS_WRITE_FORMAT_COVERSION[unicode] = "string"  # noqa: F821
    ODS_WRITE_FORMAT_COVERSION[long] = "throw_exception"  # noqa: F821

...

def throw_exception(value):
     # after a closer look, it was thrown here.
    raise exceptions.IntegerAccuracyLossError("%s is too big" % value) 


def ods_float_value(value):
      # I thought it was thrown here. At the time of fixing, I could not see why it fails. Now it is clear
    if int(value) > int(constants.MAX_INTEGER):
        raise exceptions.IntegerAccuracyLossError("%s is too big" % value)
    return value
def test_issue_30():
    test_file = "issue_30.ods"
    sheet = pe.Sheet()
    sheet[0, 0] = 999999999999999 # was interpreted as long.
    sheet.save_as(test_file) 
    sheet2 = pe.get_sheet(file_name=test_file)
    eq_(sheet[0, 0], sheet2[0, 0])
    os.unlink(test_file)

@chfw
Copy link
Member

chfw commented Mar 19, 2019

new release has been made: pyexcel-io 0.5.16, pyexcel-ods 0.5.6

@anton-kaidalov
Copy link

anton-kaidalov commented Mar 28, 2019

Guys, I'm experiencing a similar problem with pyexcel_ods3 0.5.3 on Python 3.7.3. Is this expected and happens because the fixes from pyexcel-ods 0.5.6 are not yet incorporated into ods3?

The steps to reproduce are fairly simple:

  • I have an ods file that contains value 72518656881440400 stored as a number;
  • read_data() correctly reads the file;
  • subsequent save_data() fails with pyexcel_io.exceptions.IntegerAccuracyLossError: 72518656881440400 is too big.

@chfw
Copy link
Member

chfw commented Mar 28, 2019

Please try: pyexcel-io 0.5.16

@anton-kaidalov
Copy link

anton-kaidalov commented Apr 1, 2019

@chfw
I'm already using exactly pyexcel-io 0.5.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants