features/pep-433: 963e450fc24f (original) (raw)

--- a/Lib/bz2.py +++ b/Lib/bz2.py @@ -95,7 +95,7 @@ class BZ2File(io.BufferedIOBase): raise ValueError("Invalid mode: %r" % (mode,)) if isinstance(filename, (str, bytes)):

--- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -102,7 +102,7 @@ def compile_file(fullname, ddir=None, fo try: mtime = int(os.stat(fullname).st_mtime) expect = struct.pack('<4sl', imp.get_magic(), mtime)

@@ -206,7 +206,7 @@ def main(): # if flist is provided then load it if args.flist: try:

--- a/Lib/dbm/dumb.py +++ b/Lib/dbm/dumb.py @@ -77,7 +77,7 @@ class _Database(collections.MutableMappi def _update(self): self._index = {} try:

@@ -108,7 +108,7 @@ class _Database(collections.MutableMappi except OSError: pass

@@ -122,7 +122,7 @@ class _Database(collections.MutableMappi if isinstance(key, str): key = key.encode('utf-8') pos, siz = self._index[key] # may raise KeyError

@@ -133,7 +133,7 @@ class _Database(collections.MutableMappi # to get to an aligned offset. Return pair # (starting offset of val, len(val)) def _addval(self, val):

@@ -148,7 +148,7 @@ class _Database(collections.MutableMappi # pos to hold val, without overwriting some other value. Return # pair (pos, len(val)). def _setval(self, pos, val):

@@ -159,7 +159,7 @@ class _Database(collections.MutableMappi # the in-memory index dict, and append one to the directory file. def _addkey(self, key, pos_and_siz_pair): self._index[key] = pos_and_siz_pair

--- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -222,7 +222,7 @@ def _load_testfile(filename, package, mo # get_data() opens files as 'rb', so one must do the equivalent # conversion as universal newlines would do. return file_contents.replace(os.linesep, '\n'), filename

def _indent(s, indent=4):

--- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -67,7 +67,7 @@ def _sig(st): def _do_cmp(f1, f2): bufsize = BUFSIZE

--- a/Lib/fileinput.py +++ b/Lib/fileinput.py @@ -330,18 +330,18 @@ class FileInput: pass # The next few lines may raise OSError os.rename(self._filename, self._backupfilename)

@@ -354,7 +354,7 @@ class FileInput: if self._openhook: self._file = self._openhook(self._filename, self._mode) else:

@@ -396,12 +396,12 @@ def hook_compressed(filename, mode): import bz2 return bz2.BZ2File(filename, mode) else:

def hook_encoded(encoding): def openhook(filename, mode):

--- a/Lib/gettext.py +++ b/Lib/gettext.py @@ -406,7 +406,7 @@ def translation(domain, localedir=None, key = (class_, os.path.abspath(mofile)) t = _translations.get(key) if t is None:

--- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -181,7 +181,7 @@ class GzipFile(io.BufferedIOBase): if mode and 'b' not in mode: mode += 'b' if fileobj is None:

--- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1761,7 +1761,7 @@ class FileCookieJar(CookieJar): if self.filename is not None: filename = self.filename else: raise ValueError(MISSING_FILENAME_TEXT)

@@ -1856,7 +1856,7 @@ class LWPCookieJar(FileCookieJar): if self.filename is not None: filename = self.filename else: raise ValueError(MISSING_FILENAME_TEXT)

@@ -2055,7 +2055,7 @@ class MozillaCookieJar(FileCookieJar): if self.filename is not None: filename = self.filename else: raise ValueError(MISSING_FILENAME_TEXT)

--- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -9,7 +9,7 @@ def what(file, h=None): if h is None: if isinstance(file, str):

--- a/Lib/imp.py +++ b/Lib/imp.py @@ -221,9 +221,9 @@ def find_module(name, path=None): encoding = None if mode == 'U':

--- a/Lib/lzma.py +++ b/Lib/lzma.py @@ -124,7 +124,7 @@ class LZMAFile(io.BufferedIOBase): if isinstance(filename, (str, bytes)): if "b" not in mode: mode += "b"

--- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -366,7 +366,7 @@ class Maildir(Mailbox): def get_message(self, key): """Return a Message representation or raise a KeyError.""" subpath = self._lookup(key)

@@ -383,7 +383,7 @@ class Maildir(Mailbox): def get_bytes(self, key): """Return a bytes representation or raise a KeyError."""

@@ -391,7 +391,7 @@ class Maildir(Mailbox): def get_file(self, key): """Return a file-like representation or raise a KeyError."""

def iterkeys(self): @@ -454,7 +454,7 @@ class Maildir(Mailbox): maildirfolder_path = os.path.join(path, 'maildirfolder') if not os.path.exists(maildirfolder_path): os.close(os.open(maildirfolder_path, os.O_CREAT | os.O_WRONLY,

def remove_folder(self, folder): @@ -584,15 +584,15 @@ class _singlefileMailbox(Mailbox): """Initialize a single-file mailbox.""" Mailbox.init(self, path, factory, create) try:

@@ -712,7 +712,7 @@ class _singlefileMailbox(Mailbox): os.rename(new_file.name, self._path) else: raise

@@ -944,8 +944,7 @@ class MH(Mailbox): if create: os.mkdir(self._path, 0o700) os.close(os.open(os.path.join(self._path, '.mh_sequences'),

@@ -988,7 +987,7 @@ class MH(Mailbox): """Remove the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try:

@@ -1002,7 +1001,7 @@ class MH(Mailbox): """Replace the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try:

@@ -1012,7 +1011,7 @@ class MH(Mailbox): if self._locked: _lock_file(f) try:

@@ -1026,9 +1025,9 @@ class MH(Mailbox): """Return a Message representation or raise a KeyError.""" try: if self._locked:

@@ -1053,9 +1052,9 @@ class MH(Mailbox): """Return a bytes representation or raise a KeyError.""" try: if self._locked:

@@ -1075,7 +1074,7 @@ class MH(Mailbox): def get_file(self, key): """Return a file-like representation or raise a KeyError.""" try:

@@ -1099,7 +1098,7 @@ class MH(Mailbox): def lock(self): """Lock the mailbox.""" if not self._locked:

@@ -1153,7 +1152,7 @@ class MH(Mailbox): def get_sequences(self): """Return a name-to-key-list dictionary to define each sequence.""" results = {}

@@ -1176,9 +1175,9 @@ class MH(Mailbox): def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary."""

@@ -2115,9 +2114,9 @@ def _unlock_file(f): def _create_carefully(path): """Create a file if it doesn't exist and open for reading and writing."""

--- a/Lib/mailcap.py +++ b/Lib/mailcap.py @@ -19,7 +19,7 @@ def getcaps(): caps = {} for mailcap in listmailcapfiles(): try:

--- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -199,7 +199,7 @@ class MimeTypes: list of standard types, else to the list of non-standard types. """

def readfp(self, fp, strict=True): @@ -358,7 +358,7 @@ def init(files=None): def read_mime_types(file): try:

--- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -102,14 +102,14 @@ class ModuleFinder: def run_script(self, pathname): self.msg(2, "run_script", pathname)

def load_file(self, pathname): dir, name = os.path.split(pathname) name, ext = os.path.splitext(name)

--- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -28,7 +28,7 @@ class netrc: raise OSError("Could not find .netrc: $HOME is not set") self.hosts = {} self.macros = {}

def _parse(self, file, fp):

--- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -464,7 +464,7 @@ class _NNTPBase: try: # If a string was passed then open a file with that name if isinstance(file, (str, bytes)):

resp = self._getresp() if resp[:3] not in _LONGRESP:

--- a/Lib/optparse.py +++ b/Lib/optparse.py @@ -880,9 +880,7 @@ class Values: def read_file(self, filename, mode="careful"): vars = {}

def ensure_value(self, attr, value):

--- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -91,7 +91,7 @@ class Restart(Exception): def find_function(funcname, filename): cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try:

@@ -1533,7 +1533,7 @@ class Pdb(bdb.Bdb, cmd.Cmd): self._wait_for_mainpyfile = True self.mainpyfile = self.canonic(filename) self._user_requested_quit = False

--- a/Lib/pipes.py +++ b/Lib/pipes.py @@ -153,7 +153,7 @@ class Template: """t.open_r(file) and t.open_w(file) implement t.open(file, 'r') and t.open(file, 'w') respectively.""" if not self.steps:

@@ -161,7 +161,7 @@ class Template: def open_w(self, file): if not self.steps:

--- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -297,16 +297,16 @@ class ImpLoader: return mod def get_data(self, pathname):

def _reopen(self): if self.file and self.file.closed: mod_type = self.etc[2] if mod_type==imp.PY_SOURCE:

def _fix_name(self, fullname): if fullname is None: @@ -349,7 +349,7 @@ class ImpLoader: self.file.close() elif mod_type==imp.PY_COMPILED: if os.path.exists(self.filename[:-1]):

@@ -586,7 +586,7 @@ def extend_path(path, name): pkgfile = os.path.join(dir, sname_pkg) if os.path.isfile(pkgfile): try:

--- a/Lib/platform.py +++ b/Lib/platform.py @@ -159,7 +159,7 @@ def libc_ver(executable=sys.executable,l # here to work around problems with Cygwin not being # able to open symlinks for reading executable = os.path.realpath(executable)

@@ -222,7 +222,7 @@ def _dist_try_harder(distname,version,id if os.path.exists('/etc/.installed'): # Caldera OpenLinux has some infos in that file (thanks to Colin Kong)

@@ -331,7 +331,7 @@ def linux_distribution(distname='', vers return _dist_try_harder(distname,version,id) # Read the first line

--- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -70,7 +70,7 @@ def readPlist(pathOrFile): didOpen = False try: if isinstance(pathOrFile, str):

@@ -87,7 +87,7 @@ def writePlist(rootObject, pathOrFile): didOpen = False try: if isinstance(pathOrFile, str):

--- a/Lib/profile.py +++ b/Lib/profile.py @@ -373,7 +373,7 @@ class Profile: print_stats() def dump_stats(self, file):

@@ -554,7 +554,7 @@ def main(): if len(args) > 0: progname = args[0] sys.path.insert(0, os.path.dirname(progname))

--- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -93,7 +93,7 @@ class Stats: self.stats = {} return elif isinstance(arg, str):

@@ -149,7 +149,7 @@ class Stats: def dump_stats(self, filename): """Write the profile data to a file we know how to load back."""

--- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -138,7 +138,7 @@ def compile(file, cfile=None, dfile=None except OSError as error: if error.errno != errno.EEXIST: raise

--- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -198,11 +198,11 @@ def _get_main_module_details(): def _get_code_from_file(run_name, fname): # Check for a compiled file first

--- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -249,7 +249,7 @@ class shlex: # This implements cpp-like semantics for relative-path inclusion. if isinstance(self.infile, str) and not os.path.isabs(newfile): newfile = os.path.join(os.path.dirname(self.infile), newfile)

def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." @@ -295,7 +295,7 @@ if name == 'main': lexer = shlex() else: file = sys.argv[1]

--- a/Lib/site.py +++ b/Lib/site.py @@ -152,7 +152,7 @@ def addpackage(sitedir, name, known_path reset = 0 fullname = os.path.join(sitedir, name) try:

@@ -499,7 +499,7 @@ def venv(known_paths): if candidate_confs: virtual_conf = candidate_confs[0] system_site = "true"

--- a/Lib/sndhdr.py +++ b/Lib/sndhdr.py @@ -40,7 +40,7 @@ def what(filename): def whathdr(filename): """Recognize sound headers."""

--- a/Lib/sunau.py +++ b/Lib/sunau.py @@ -153,7 +153,7 @@ class Au_read: def init(self, f): if type(f) == type(''): import builtins

@@ -287,7 +287,7 @@ class Au_write: def init(self, f): if type(f) == type(''): import builtins

--- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -231,7 +231,7 @@ def _parse_makefile(filename, vars=None) done = {} notdone = {}

for line in lines: @@ -357,7 +357,7 @@ def _generate_posix_vars(): # load the installed pyconfig.h: config_h = get_config_h_filename() try:

@@ -394,14 +394,14 @@ def _generate_posix_vars(): os.makedirs(pybuilddir, exist_ok=True) destfile = os.path.join(pybuilddir, name + '.py')

# Create file used for sys.path fixup -- see Modules/getpath.c

def _init_posix(vars):

--- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -332,7 +332,7 @@ class _LowLevelFile: }[mode] if hasattr(os, "O_BINARY"): mode |= os.O_BINARY

def close(self): os.close(self.fd) @@ -1439,7 +1439,7 @@ class TarFile(object): # Create nonexistent files in append mode. self.mode = "w" self._mode = "wb"

--- a/Lib/tkinter/init.py +++ b/Lib/tkinter/init.py @@ -1849,15 +1849,11 @@ class Tk(Misc, Wm): if os.path.isfile(class_tcl): self.tk.call('source', class_tcl) if os.path.isfile(class_py):

--- a/Lib/tkinter/filedialog.py +++ b/Lib/tkinter/filedialog.py @@ -395,7 +395,7 @@ def askopenfile(mode = "r", **options): filename = Open(**options).show() if filename:

--- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -425,7 +425,7 @@ def open(filename): """Open a file in read only mode using the encoding detected by detect_encoding(). """

--- a/Lib/trace.py +++ b/Lib/trace.py @@ -235,7 +235,7 @@ class CoverageResults: # Try to merge existing counts file. try: counts, calledfuncs, callers = [](#l38.6)

@@ -328,7 +328,7 @@ class CoverageResults: source = linecache.getlines(filename) coverpath = os.path.join(dir, modulename + ".cover")

@@ -346,7 +346,7 @@ class CoverageResults: # try and store counts and module info into self.outfile try: pickle.dump((self.counts, self.calledfuncs, self.callers),

@@ -354,7 +354,7 @@ class CoverageResults: """Return a coverage results file in path.""" try:

@@ -418,7 +418,7 @@ def _find_strings(filename, encoding=Non # If the first token is a string, then it's the module docstring. # Add this special case so that the test in the loop passes. prev_ttype = token.INDENT

@@ -791,7 +791,7 @@ def main(argv=None): ignoredirs=ignore_dirs, infile=counts_file, outfile=counts_file, timing=timing) try:

--- a/Lib/turtle.py +++ b/Lib/turtle.py @@ -169,7 +169,7 @@ from tkinter import simpledialog def config_dict(filename): """Convert content of config-file into dictionary."""

--- a/Lib/turtledemo/main.py +++ b/Lib/turtledemo/main.py @@ -188,7 +188,7 @@ class DemoWindow(object): modname = 'turtledemo.' + filename import(modname) self.module = sys.modules[modname]

--- a/Lib/uu.py +++ b/Lib/uu.py @@ -56,7 +56,7 @@ def encode(in_file, out_file, name=None, mode = os.stat(in_file).st_mode except AttributeError: pass

@@ -64,7 +64,7 @@ def encode(in_file, out_file, name=None, if out_file == '-': out_file = sys.stdout.buffer elif isinstance(out_file, str):

@@ -96,7 +96,7 @@ def decode(in_file, out_file=None, mode= if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str):

try: @@ -129,7 +129,7 @@ def decode(in_file, out_file=None, mode= if out_file == '-': out_file = sys.stdout.buffer elif isinstance(out_file, str):

@@ -181,7 +181,7 @@ def test(): if options.decode: if options.text: if isinstance(output, str):

@@ -189,7 +189,7 @@ def test(): else: if options.text: if isinstance(input, str):

--- a/Lib/wave.py +++ b/Lib/wave.py @@ -156,7 +156,7 @@ class Wave_read: def init(self, f): self._i_opened_the_file = None if isinstance(f, str):

@@ -300,7 +300,7 @@ class Wave_write: def init(self, f): self._i_opened_the_file = None if isinstance(f, str):

--- a/Lib/xml/dom/expatbuilder.py +++ b/Lib/xml/dom/expatbuilder.py @@ -905,7 +905,7 @@ def parse(file, namespaces=True): builder = ExpatBuilder() if isinstance(file, str):

@@ -939,7 +939,7 @@ def parseFragment(file, context, namespa builder = FragmentBuilder(context) if isinstance(file, str):

--- a/Lib/xml/dom/pulldom.py +++ b/Lib/xml/dom/pulldom.py @@ -325,7 +325,7 @@ def parse(stream_or_string, parser=None, if bufsize is None: bufsize = default_bufsize if isinstance(stream_or_string, str):

--- a/Lib/xml/etree/ElementInclude.py +++ b/Lib/xml/etree/ElementInclude.py @@ -76,12 +76,12 @@ class FatalIncludeError(SyntaxError): def default_loader(href, parse, encoding=None): if parse == "xml":

--- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -651,7 +651,7 @@ class ElementTree: def parse(self, source, parser=None): close_source = False if not hasattr(source, "read"):

@@ -844,10 +844,10 @@ def _get_writer(file_or_filename, encodi except AttributeError: # file_or_filename is a file name if encoding == "unicode":

@@ -1724,7 +1724,7 @@ else: def parse(self, source, parser=None): close_source = False if not hasattr(source, 'read'):

@@ -1747,7 +1747,7 @@ else: def init(self, file, events=None): self._close_file = False if not hasattr(file, 'read'):

--- a/Lib/xml/sax/saxutils.py +++ b/Lib/xml/sax/saxutils.py @@ -321,7 +321,7 @@ def prepare_input_source(source, base="" sysidfilename = os.path.join(basehead, sysid) if os.path.isfile(sysidfilename): source.setSystemId(sysidfilename)

--- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -178,7 +178,7 @@ def is_zipfile(filename): if hasattr(filename, "read"): result = _check_zipfile(fp=filename) else:

@@ -899,11 +899,11 @@ class ZipFile: self.filename = file modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'} try:

@@ -1109,7 +1109,7 @@ class ZipFile: if self._filePassed: zef_file = self.fp else:

try: # Make sure we have an info object @@ -1240,7 +1240,7 @@ class ZipFile: return targetpath with self.open(member, pwd=pwd) as source, [](#l48.38)

return targetpath @@ -1310,7 +1310,7 @@ class ZipFile: return cmpr = _get_compressor(zinfo.compress_type)

@@ -1710,7 +1710,7 @@ def main(args = None): tgtdir = os.path.dirname(tgt) if not os.path.exists(tgtdir): os.makedirs(tgtdir)

elif args[0] == '-c':