twisted / twisted/twisted

twisted.test.test_paths.UnicodeFilePathTests fails if LANG=C

Open
#8,078 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core new priority-normal
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

tomprince's avatar @tomprince reported
Trac ID trac#8078
Type defect
Created 2015-10-30 07:11:48Z
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1696, in test_BytesInstantiationUnicodeChild
    child = fp.child(u"mon\u20acy")
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 843, in child
    ourPath = self._getPathAsSameTypeAs(path)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 823, in _getPathAsSameTypeAs
    return self._asTextPath()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 781, in _asTextPath
    return _asFilesystemText(self.path, encoding=encoding)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 641, in _asFilesystemText
    return path.decode(encoding)
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 50: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_BytesInstantiationUnicodeChild
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1716, in test_BytesInstantiationUnicodePreauthChild
    child = fp.preauthChild(u"mon\u20acy")
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 872, in preauthChild
    ourPath = self._getPathAsSameTypeAs(path)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 823, in _getPathAsSameTypeAs
    return self._asTextPath()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 781, in _asTextPath
    return _asFilesystemText(self.path, encoding=encoding)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 641, in _asFilesystemText
    return path.decode(encoding)
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 50: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_BytesInstantiationUnicodePreauthChild
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1637, in test_UnicodeInstantiationBytesChild
    child = fp.child(u'child-mon\u20acy'.encode('utf-8'))
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 843, in child
    ourPath = self._getPathAsSameTypeAs(path)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 821, in _getPathAsSameTypeAs
    return self._asBytesPath()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 769, in _asBytesPath
    return _asFilesystemBytes(self.path, encoding=encoding)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 619, in _asFilesystemBytes
    return path.encode(encoding)
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 50: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_UnicodeInstantiationBytesChild
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1667, in test_UnicodeInstantiationBytesPreauthChild
    child = fp.preauthChild(u'child-mon\u20acy'.encode('utf-8'))
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 872, in preauthChild
    ourPath = self._getPathAsSameTypeAs(path)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 821, in _getPathAsSameTypeAs
    return self._asBytesPath()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 769, in _asBytesPath
    return _asFilesystemBytes(self.path, encoding=encoding)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 619, in _asFilesystemBytes
    return path.encode(encoding)
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 50: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_UnicodeInstantiationBytesPreauthChild
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1922, in test_mixedTypeChildSearchPreauth
    fp.createDirectory()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1549, in createDirectory
    os.mkdir(self.path)
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_mixedTypeChildSearchPreauth
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1893, in test_mixedTypeSiblingExtension
    sibling.touch()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1393, in touch
    self.open('a').close()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1010, in open
    return open(self.path, mode + 'b')
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_mixedTypeSiblingExtension
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1864, in test_mixedTypeSiblingExtensionSearch
    sibling.touch()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1393, in touch
    self.open('a').close()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1010, in open
    return open(self.path, mode + 'b')
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_mixedTypeSiblingExtensionSearch
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1843, in test_mixedTypeTemporarySibling
    tempSibling = fp.temporarySibling(b".txt")
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1598, in temporarySibling
    ourPath = self._getPathAsSameTypeAs(extension)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 821, in _getPathAsSameTypeAs
    return self._asBytesPath()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 769, in _asBytesPath
    return _asFilesystemBytes(self.path, encoding=encoding)
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 619, in _asFilesystemBytes
    return path.encode(encoding)
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_mixedTypeTemporarySibling
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1939, in test_unicodeChildSearchPreauth
    fp.createDirectory()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1549, in createDirectory
    os.mkdir(self.path)
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_unicodeChildSearchPreauth
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1908, in test_unicodeSiblingExtension
    sibling.touch()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1393, in touch
    self.open('a').close()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1010, in open
    return open(self.path, mode + 'b')
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_unicodeSiblingExtension
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/tomprince/src/twisted/twisted/test/test_paths.py", line 1878, in test_unicodeSiblingExtensionSearch
    sibling.touch()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1393, in touch
    self.open('a').close()
  File "/home/tomprince/src/twisted/twisted/python/filepath.py", line 1010, in open
    return open(self.path, mode + 'b')
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u20ac' in position 43: ordinal not in range(128)

twisted.test.test_paths.UnicodeFilePathTests.test_unicodeSiblingExtensionSearch
-------------------------------------------------------------------------------
Searchable metadata
trac-id__8078 8078
type__defect defect
reporter__tom_prince tom.prince
priority__normal normal
milestone__None None
branch__ 
branch_author__ 
status__new new
resolution__None None
component__core core
keywords__None None
time__1446189108964184 1446189108964184
changetime__1446189108964184 1446189108964184
version__None None
owner__None None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with LANG=C and run twisted.test.test_paths.UnicodeFilePathTests. Read twisted/test/test_paths.py alongside the referenced conversion and filesystem operations in twisted/python/filepath.py. Done means the UnicodeFilePathTests pass under LANG=C without changing their intended Unicode and bytes behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.