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

python 2.7 incompatibilities #4

Closed
jcrobak opened this issue Jan 2, 2013 · 3 comments
Closed

python 2.7 incompatibilities #4

jcrobak opened this issue Jan 2, 2013 · 3 comments

Comments

@jcrobak
Copy link
Contributor

jcrobak commented Jan 2, 2013

I can run the tests with python 2.6 but not python 2.7. With python 2.7, several tests in _hdfs_tests.py fail:

======================================================================
ERROR: test_with_noclose (_hdfs_test.AtomicHdfsOutputPipeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/joe/Code/luigi/test/_hdfs_test.py", line 53, in test_with_noclose
    self.assertRaises(TestException, foo)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 471, in assertRaises
    callableObj(*args, **kwargs)
  File "/Users/joe/Code/luigi/test/_hdfs_test.py", line 50, in foo
    with hdfs.HdfsAtomicWritePipe(testpath) as fobj:
AttributeError: __enter__

======================================================================
ERROR: test_glob_exists (_hdfs_test.HdfsTargetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/joe/Code/luigi/test/_hdfs_test.py", line 190, in test_glob_exists
    with t1.open('w') as f:
AttributeError: __enter__

That's just a small sample but gives you an idea of the stacktrace. My python fu isn't really that great, so I'm not sure why it works on python 2.6 at all. Is fixing the 2.7 compatibility just a matter of adding enter and close ?

@erikbern
Copy link
Contributor

erikbern commented Jan 3, 2013

Interesting. This code works in 2.6 but not in 2.7:

class X(object):
    def __init__(self):
        self.f = open('test.txt', 'w')

    def __getattr__(self, name):
        return getattr(self.f, name)

with X():
    pass

Adding dummy __enter__ and __exit__ resolves it. Will push a fix soon.

@erikbern
Copy link
Contributor

erikbern commented Jan 3, 2013

Pushed a fix, let me know if the problem persists.

@jcrobak
Copy link
Contributor Author

jcrobak commented Jan 3, 2013

your fix resolves the issue for me. Thanks!

@jcrobak jcrobak closed this as completed Jan 3, 2013
dlstadther pushed a commit that referenced this issue Nov 12, 2024
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

2 participants