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

path.walkdirs() unicode problem #41

Closed
franciscolourenco opened this issue Jul 14, 2013 · 10 comments
Closed

path.walkdirs() unicode problem #41

franciscolourenco opened this issue Jul 14, 2013 · 10 comments

Comments

@franciscolourenco
Copy link
Contributor

Traceback (most recent call last):
  File "./cleanup.py", line 104, in <module>
    for subdir in reversed(list(path(dir).walkdirs())):
  File "/usr/local/lib/python2.7/dist-packages/path.py", line 535, in walkdirs
    dirs = self.dirs()
  File "/usr/local/lib/python2.7/dist-packages/path.py", line 450, in dirs
    return [p for p in self.listdir(pattern) if p.isdir()]
  File "/usr/local/lib/python2.7/dist-packages/path.py", line 437, in listdir
    return [self / child for child in names]
  File "/usr/local/lib/python2.7/dist-packages/path.py", line 201, in __div__
    return self._next_class(self.module.join(self, rel))
  File "/usr/lib/python2.7/posixpath.py", line 69, in join
    path +=  b
  File "/usr/local/lib/python2.7/dist-packages/path.py", line 185, in __add__
    return self._next_class(super(path, self).__add__(more))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 11: ordinal not in range(128)
@jaraco
Copy link
Owner

jaraco commented Aug 31, 2013

In 871408c, I added a test in an attempt to recreate this error, but the tests still pass. I'll need more information to replicate the issue. Were you on Python 2 or Python 3? What OS? What file system encoding? What paths were in the tree (in particular, non-ascii paths)?

@franciscolourenco
Copy link
Contributor Author

You forget to add unittest.TestCase to the test class :P

@jaraco
Copy link
Owner

jaraco commented Oct 27, 2013

So while the test derives from unittest.TestCase, the tests still pass on all Python versions on both Linux and Windows. I suspect the issue has something to do with the file system encoding, but I'm not familiar with the nuances of file system encodings, and the issue doesn't seem to exist in a clean environment, so without better information, this issue won't be fixed.

@jaraco jaraco closed this as completed Oct 27, 2013
@franciscolourenco
Copy link
Contributor Author

Which Linux flavour and version did you use to test?

@jaraco
Copy link
Owner

jaraco commented Oct 27, 2013

The tests run continuously on Travis – CI. I believe it uses Ubuntu 10.

@jaraco
Copy link
Owner

jaraco commented Oct 28, 2013

Correction - Ubuntu Precise (12.04) LTS is what Travis-CI uses. The tests are linked from the README, so visible from the pypi page and project home.

@franciscolourenco
Copy link
Contributor Author

running test_path.py manually fails with:

....................................E
======================================================================
ERROR: test_walkdirs_with_unicode_name (__main__.TestUnicodePaths)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_path.py", line 789, in test_walkdirs_with_unicode_name
    p = path(self.tempdir)
AttributeError: 'TestUnicodePaths' object has no attribute 'tempdir'

----------------------------------------------------------------------
Ran 37 tests in 10.074s

FAILED (errors=1)
root@debian:/home/user/path.py# python test_path.py

@jaraco
Copy link
Owner

jaraco commented Oct 28, 2013

The test that's failing is depending on py.test to invoke setup_method. This requirement needs to be made more explicit, but it is the way tests are run on travis (see .travis.yml for specifics on how the tests are run, or simply run 'py.test' with pytest installed).

@franciscolourenco
Copy link
Contributor Author

I can't reproduce the issue anymore, so.. no bug
Maybe I've got rid of the offending directories, because I'm testing in the same system...
However I could almost swear the snowman test failed before with "UnicodeDecodeError" strange..

Anyway, thank you for the support!

@jaraco
Copy link
Owner

jaraco commented Oct 28, 2013

Glad to help. And thanks for your patience.

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