BUG: open csvfile with newline='' on Python 3 #70

Merged
merged 1 commit into from Oct 16, 2013

Conversation

Projects
None yet
2 participants
Contributor

cgohlke commented Oct 16, 2013

See http://docs.python.org/3/library/csv.html#csv.writer:

If newline='' is not specified, newlines embedded inside quoted fields will not 
be interpreted correctly, and on platforms that use \r\n linendings on write an 
extra \r will be added. It should always be safe to specify newline='', since the 
csv module does its own (universal) newline handling.

Fixes one test error on Python 3.x on Windows:

======================================================================
ERROR: Failure: IndexError (pop from empty list)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python32\lib\site-packages\nose\failure.py", line 38, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "X:\Python32\lib\site-packages\nose\loader.py", line 254, in generate
    for test in g():
  File "X:\Python32\lib\site-packages\la\tests\deflarry_creation_test.py", line 95, in test_conversion
    y2 = larry.fromcsv(filename)
  File "X:\Python32\lib\site-packages\la\deflarry.py", line 4825, in fromcsv
    return larry.fromtuples(data)
  File "X:\Python32\lib\site-packages\la\deflarry.py", line 4554, in fromtuples
    xs = labels.pop(-1)
IndexError: pop from empty list
Owner

kwgoodman commented Oct 16, 2013

Thanks again. This fix works on ubuntu/python3.3/numpy171.

@kwgoodman kwgoodman added a commit that referenced this pull request Oct 16, 2013

@kwgoodman kwgoodman Merge pull request #70 from cgohlke/patch-2
BUG: open csvfile with newline='' on Python 3
e9e0d24

@kwgoodman kwgoodman merged commit e9e0d24 into kwgoodman:master Oct 16, 2013

Owner

kwgoodman commented Oct 17, 2013

Do all tests now pass on windows? If so, I'll add something to the release.rst file.

Contributor

cgohlke commented Oct 17, 2013

All tests pass on Python 2.6 to 3.2. One test sometimes fails on Python 3.3 (probably due to randomized dict ordering):

======================================================================
FAIL: func.stack_1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python33\lib\site-packages\la\tests\flarry_test.py", line 138, in test_stack_1
    ale(actual, desired, msg='stack test #1')
  File "X:\Python33\lib\site-packages\la\util\testing.py", line 209, in assert_larry_equal
    raise AssertionError(err_msg)
AssertionError:

-------------------
TEST: stack test #1
-------------------


        -----
        LABEL
        -----

        Items are not equal:
        item=0
        item=0

         ACTUAL: 'name1'
         DESIRED: 'othername'

        ------------
        X DATA ARRAY
        ------------

        Arrays are not almost equal to 13 decimals

        (mismatch 100.0%)
         x: array([[[ 1.,  2.],
                [ 3.,  4.]],
        ...
         y: array([[[ 5.,  6.],
                [ 7.,  8.]],
        ...
Owner

kwgoodman commented Oct 17, 2013

I seem the same failure on ubuntu/python3.3.

kwgoodman referenced this pull request Oct 17, 2013

Closed

Python 3.3 test failure #71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment