summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-03-26 23:13:59 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-03-26 23:13:59 (GMT)
commit3784c6b1af17965de8c3c27e071b91e8a1a30848 (patch)
treeec732391b65b60f6e5fe608c8f8165d4109fe38f /Lib
parentdf70e05d2204aad60396c4f110d9783269708843 (diff)
downloadcpython-3784c6b1af17965de8c3c27e071b91e8a1a30848.zip
cpython-3784c6b1af17965de8c3c27e071b91e8a1a30848.tar.gz
cpython-3784c6b1af17965de8c3c27e071b91e8a1a30848.tar.bz2
Use the new unicode literals for the io module
use basestring instead of str in Python 2.x
Diffstat (limited to 'Lib')
-rw-r--r--Lib/io.py14
-rw-r--r--Lib/test/test_io.py1
2 files changed, 9 insertions, 6 deletions
diff --git a/Lib/io.py b/Lib/io.py
index 334b34c..310c77f 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -19,6 +19,8 @@ XXX buffered readinto should work with arbitrary buffer objects
XXX use incremental encoder for text output, at least for UTF-16 and UTF-8-SIG
XXX check writable, readable and seekable in appropriate places
"""
+from __future__ import print_function
+from __future__ import unicode_literals
__author__ = ("Guido van Rossum <guido@python.org>, "
"Mike Verdone <mike.verdone@gmail.com>, "
@@ -110,15 +112,15 @@ def open(file, mode="r", buffering=None, encoding=None, errors=None,
binary stream, a buffered binary stream, or a buffered text
stream, open for reading and/or writing.
"""
- if not isinstance(file, (str, unicode, int)):
+ if not isinstance(file, (basestring, int)):
raise TypeError("invalid file: %r" % file)
- if not isinstance(mode, str):
+ if not isinstance(mode, basestring):
raise TypeError("invalid mode: %r" % mode)
if buffering is not None and not isinstance(buffering, int):
raise TypeError("invalid buffering: %r" % buffering)
- if encoding is not None and not isinstance(encoding, str):
+ if encoding is not None and not isinstance(encoding, basestring):
raise TypeError("invalid encoding: %r" % encoding)
- if errors is not None and not isinstance(errors, str):
+ if errors is not None and not isinstance(errors, basestring):
raise TypeError("invalid errors: %r" % errors)
modes = set(mode)
if modes - set("arwb+tU") or len(mode) > len(modes):
@@ -1163,13 +1165,13 @@ class TextIOWrapper(TextIOBase):
else:
encoding = locale.getpreferredencoding()
- if not isinstance(encoding, str):
+ if not isinstance(encoding, basestring):
raise ValueError("invalid encoding: %r" % encoding)
if errors is None:
errors = "strict"
else:
- if not isinstance(errors, str):
+ if not isinstance(errors, basestring):
raise ValueError("invalid errors: %r" % errors)
self.buffer = buffer
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 1791705..e26b708 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1,5 +1,6 @@
"""Unit tests for io.py."""
from __future__ import print_function
+from __future__ import unicode_literals
import os
import sys