mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 13:33:09 +00:00
Another function that should be a no-op on Python 3.
This commit is contained in:
parent
2cc2cb6a7f
commit
03ed0fd66f
@ -144,6 +144,7 @@ class EncodingUtilErrors(ReallyEqualMixin, unittest.TestCase):
|
|||||||
argv_to_unicode,
|
argv_to_unicode,
|
||||||
lumiere_nfc.encode('latin1'))
|
lumiere_nfc.encode('latin1'))
|
||||||
|
|
||||||
|
@skipIf(PY3, "Python 2 only.")
|
||||||
def test_unicode_to_output(self):
|
def test_unicode_to_output(self):
|
||||||
encodingutil.io_encoding = 'koi8-r'
|
encodingutil.io_encoding = 'koi8-r'
|
||||||
self.failUnlessRaises(UnicodeEncodeError, unicode_to_output, lumiere_nfc)
|
self.failUnlessRaises(UnicodeEncodeError, unicode_to_output, lumiere_nfc)
|
||||||
@ -228,7 +229,8 @@ class EncodingUtil(ReallyEqualMixin):
|
|||||||
def test_unicode_to_url(self):
|
def test_unicode_to_url(self):
|
||||||
self.failUnless(unicode_to_url(lumiere_nfc), b"lumi\xc3\xa8re")
|
self.failUnless(unicode_to_url(lumiere_nfc), b"lumi\xc3\xa8re")
|
||||||
|
|
||||||
def test_unicode_to_output(self):
|
@skipIf(PY3, "Python 3 is always Unicode, regardless of OS.")
|
||||||
|
def test_unicode_to_output_py2(self):
|
||||||
if 'argv' not in dir(self):
|
if 'argv' not in dir(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -239,6 +241,10 @@ class EncodingUtil(ReallyEqualMixin):
|
|||||||
_reload()
|
_reload()
|
||||||
self.failUnlessReallyEqual(unicode_to_output(lumiere_nfc), self.argv)
|
self.failUnlessReallyEqual(unicode_to_output(lumiere_nfc), self.argv)
|
||||||
|
|
||||||
|
@skipIf(PY2, "Python 3 only.")
|
||||||
|
def test_unicode_to_output_py3(self):
|
||||||
|
self.failUnlessReallyEqual(unicode_to_output(lumiere_nfc), lumiere_nfc)
|
||||||
|
|
||||||
@skipIf(PY3, "Python 2 only.")
|
@skipIf(PY3, "Python 2 only.")
|
||||||
def test_unicode_to_argv_py2(self):
|
def test_unicode_to_argv_py2(self):
|
||||||
"""unicode_to_argv() converts to bytes on Python 2."""
|
"""unicode_to_argv() converts to bytes on Python 2."""
|
||||||
|
@ -21,6 +21,7 @@ from past.builtins import unicode
|
|||||||
|
|
||||||
import sys, os, re, locale
|
import sys, os, re, locale
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
import warnings
|
||||||
|
|
||||||
from allmydata.util.assertutil import precondition, _assert
|
from allmydata.util.assertutil import precondition, _assert
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
@ -140,6 +141,8 @@ def unicode_to_argv(s, mangle=False):
|
|||||||
"""
|
"""
|
||||||
precondition(isinstance(s, unicode), s)
|
precondition(isinstance(s, unicode), s)
|
||||||
if PY3:
|
if PY3:
|
||||||
|
warnings.warn("This will be unnecessary once Python 2 is dropped.",
|
||||||
|
DeprecationWarning)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
if mangle and sys.platform == "win32":
|
if mangle and sys.platform == "win32":
|
||||||
@ -185,6 +188,10 @@ def unicode_to_output(s):
|
|||||||
Encode an unicode object for representation on stdout or stderr.
|
Encode an unicode object for representation on stdout or stderr.
|
||||||
"""
|
"""
|
||||||
precondition(isinstance(s, unicode), s)
|
precondition(isinstance(s, unicode), s)
|
||||||
|
if PY3:
|
||||||
|
warnings.warn("This will be unnecessary once Python 2 is dropped.",
|
||||||
|
DeprecationWarning)
|
||||||
|
return s
|
||||||
|
|
||||||
try:
|
try:
|
||||||
out = s.encode(io_encoding)
|
out = s.encode(io_encoding)
|
||||||
|
Loading…
Reference in New Issue
Block a user