# HG changeset patch # Parent 0c27dd753f6cdaebad45c09c07ea097cc3da8adb Issue #13248: Remove obsolete objects and arguments. diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -134,11 +134,11 @@ .. function:: decodebytes(s) - decodestring(s) Decode the byte string *s*, which must contain one or more lines of base64 encoded data, and return a byte string containing the resulting binary data. - ``decodestring`` is a deprecated alias. + + .. versionchanged:: 3.3 Removed the *decodestring* alias. .. function:: encode(input, output) @@ -151,13 +151,13 @@ .. function:: encodebytes(s) - encodestring(s) Encode the byte string *s*, which can contain arbitrary binary data, and return a byte string containing one or more lines of base64-encoded data. :func:`encodebytes` returns a string containing one or more lines of base64-encoded data always including an extra trailing newline (``b'\n'``). - ``encodestring`` is a deprecated alias. + + .. versionchanged:: 3.3 Removed the *encodestring* alias. An example usage of the module: diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst --- a/Doc/library/cgi.rst +++ b/Doc/library/cgi.rst @@ -259,6 +259,11 @@ algorithms implemented in this module in other circumstances. +.. versionchanged:: 3.2 + The :func:`urllib.parse.parse_qs` and the :func:`urllib.parse.parse_qsl` + functions are located in the *urllib.parse* module. + + .. function:: parse(fp=None, environ=os.environ, keep_blank_values=False, strict_parsing=False) Parse a query in the environment or from a file (the file defaults to @@ -266,16 +271,6 @@ passed to :func:`urllib.parse.parse_qs` unchanged. -.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False) - - This function is deprecated in this module. Use :func:`urllib.parse.parse_qs` - instead. It is maintained here only for backward compatibility. - -.. function:: parse_qsl(qs, keep_blank_values=False, strict_parsing=False) - - This function is deprecated in this module. Use :func:`urllib.parse.parse_qs` - instead. It is maintained here only for backward compatibility. - .. function:: parse_multipart(fp, pdict) Parse input of type :mimetype:`multipart/form-data` (for file uploads). diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -27,7 +27,7 @@ The module provides the following classes: -.. class:: HTTPConnection(host, port=None[, strict[, timeout[, source_address]]]) +.. class:: HTTPConnection(host, port=None[, timeout[, source_address]]) An :class:`HTTPConnection` instance represents one transaction with an HTTP server. It should be instantiated passing it a host and optional port @@ -51,11 +51,11 @@ *source_address* was added. .. versionchanged:: 3.2 - The *strict* parameter is deprecated. HTTP 0.9-style "Simple Responses" + The *strict* parameter is removed. HTTP 0.9-style "Simple Responses" are not supported anymore. -.. class:: HTTPSConnection(host, port=None, key_file=None, cert_file=None[, strict[, timeout[, source_address]]], *, context=None, check_hostname=None) +.. class:: HTTPSConnection(host, port=None, key_file=None, cert_file=None[, timeout[, source_address]], *, context=None, check_hostname=None) A subclass of :class:`HTTPConnection` that uses SSL for communication with secure servers. Default port is ``443``. If *context* is specified, it @@ -86,17 +86,17 @@ if :data:`ssl.HAS_SNI` is true). .. versionchanged:: 3.2 - The *strict* parameter is deprecated. HTTP 0.9-style "Simple Responses" + The *strict* parameter is removed. HTTP 0.9-style "Simple Responses" are not supported anymore. -.. class:: HTTPResponse(sock, debuglevel=0[, strict], method=None, url=None) +.. class:: HTTPResponse(sock, debuglevel=0, method=None, url=None) Class whose instances are returned upon successful connection. Not instantiated directly by user. .. versionchanged:: 3.2 - The *strict* parameter is deprecated. HTTP 0.9-style "Simple Responses" + The *strict* parameter is removed. HTTP 0.9-style "Simple Responses" are not supported anymore. diff --git a/Doc/library/io.rst b/Doc/library/io.rst --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -595,8 +595,6 @@ *raw* stream. If the *buffer_size* is not given, it defaults to :data:`DEFAULT_BUFFER_SIZE`. - A third argument, *max_buffer_size*, is supported, but unused and deprecated. - :class:`BufferedWriter` provides or overrides these methods in addition to those from :class:`BufferedIOBase` and :class:`IOBase`: @@ -622,8 +620,6 @@ in the first argument. If the *buffer_size* is omitted it defaults to :data:`DEFAULT_BUFFER_SIZE`. - A third argument, *max_buffer_size*, is supported, but unused and deprecated. - :class:`BufferedRandom` is capable of anything :class:`BufferedReader` or :class:`BufferedWriter` can do. @@ -638,9 +634,6 @@ writeable respectively. If the *buffer_size* is omitted it defaults to :data:`DEFAULT_BUFFER_SIZE`. - A fourth argument, *max_buffer_size*, is supported, but unused and - deprecated. - :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods except for :meth:`~BufferedIOBase.detach`, which raises :exc:`UnsupportedOperation`. diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -39,6 +39,9 @@ * :mod:`macpath` for old-style MacOS paths * :mod:`os2emxpath` for OS/2 EMX paths +.. versionchanged:: 3.3 + *splitunc* function is removed. Use *splitdrive* instead. + .. function:: abspath(path) @@ -305,19 +308,6 @@ returns ``('.cshrc', '')``. -.. function:: splitunc(path) - - .. deprecated:: 3.1 - Use *splitdrive* instead. - - Split the pathname *path* into a pair ``(unc, rest)`` so that *unc* is the UNC - mount point (such as ``r'\\host\mount'``), if present, and *rest* the rest of - the path (such as ``r'\path\file.ext'``). For paths containing drive letters, - *unc* will always be the empty string. - - Availability: Windows. - - .. data:: supports_unicode_filenames True if arbitrary Unicode strings can be used as file names (within limitations diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -383,27 +383,20 @@ and :meth:`close`, and also supports iteration over its lines. -.. method:: TarFile.add(name, arcname=None, recursive=True, exclude=None, *, filter=None) +.. method:: TarFile.add(name, arcname=None, recursive=True, *, filter=None) Add the file *name* to the archive. *name* may be any type of file (directory, fifo, symbolic link, etc.). If given, *arcname* specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by setting *recursive* to - :const:`False`. If *exclude* is given, it must be a function that takes one - filename argument and returns a boolean value. Depending on this value the - respective file is either excluded (:const:`True`) or added - (:const:`False`). If *filter* is specified it must be a keyword argument. It + :const:`False`. If *filter* is specified it must be a keyword argument. It should be a function that takes a :class:`TarInfo` object argument and returns the changed :class:`TarInfo` object. If it instead returns :const:`None` the :class:`TarInfo` object will be excluded from the archive. See :ref:`tar-examples` for an example. .. versionchanged:: 3.2 - Added the *filter* parameter. - - .. deprecated:: 3.2 - The *exclude* parameter is deprecated, please use the *filter* parameter - instead. + Added the *filter* parameter, and removed the *exclude* parameter. .. method:: TarFile.addfile(tarinfo, fileobj=None) diff --git a/Lib/_pyio.py b/Lib/_pyio.py --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -5,7 +5,6 @@ import os import abc import codecs -import warnings import errno # Import _thread instead of threading to reduce startup cost try: @@ -1055,19 +1054,13 @@ DEFAULT_BUFFER_SIZE. """ - _warning_stack_offset = 2 - - def __init__(self, raw, - buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None): + def __init__(self, raw, buffer_size=DEFAULT_BUFFER_SIZE): if not raw.writable(): raise IOError('"raw" argument must be writable.') _BufferedIOMixin.__init__(self, raw) if buffer_size <= 0: raise ValueError("invalid buffer size") - if max_buffer_size is not None: - warnings.warn("max_buffer_size is deprecated", DeprecationWarning, - self._warning_stack_offset) self.buffer_size = buffer_size self._write_buf = bytearray() self._write_lock = Lock() @@ -1157,15 +1150,11 @@ # XXX The usefulness of this (compared to having two separate IO # objects) is questionable. - def __init__(self, reader, writer, - buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None): + def __init__(self, reader, writer, buffer_size=DEFAULT_BUFFER_SIZE): """Constructor. The arguments are two RawIO instances. """ - if max_buffer_size is not None: - warnings.warn("max_buffer_size is deprecated", DeprecationWarning, 2) - if not reader.readable(): raise IOError('"reader" argument must be readable.') @@ -1222,13 +1211,10 @@ defaults to DEFAULT_BUFFER_SIZE. """ - _warning_stack_offset = 3 - - def __init__(self, raw, - buffer_size=DEFAULT_BUFFER_SIZE, max_buffer_size=None): + def __init__(self, raw, buffer_size=DEFAULT_BUFFER_SIZE): raw._checkSeekable() BufferedReader.__init__(self, raw, buffer_size) - BufferedWriter.__init__(self, raw, buffer_size, max_buffer_size) + BufferedWriter.__init__(self, raw, buffer_size) def seek(self, pos, whence=0): if not (0 <= whence <= 2): diff --git a/Lib/argparse.py b/Lib/argparse.py --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1579,7 +1579,6 @@ usage=None, description=None, epilog=None, - version=None, parents=[], formatter_class=HelpFormatter, prefix_chars='-', @@ -1588,14 +1587,6 @@ conflict_handler='error', add_help=True): - if version is not None: - import warnings - warnings.warn( - """The "version" argument to ArgumentParser is deprecated. """ - """Please use """ - """"add_argument(..., action='version', version="N", ...)" """ - """instead""", DeprecationWarning) - superinit = super(ArgumentParser, self).__init__ superinit(description=description, prefix_chars=prefix_chars, @@ -1609,7 +1600,6 @@ self.prog = prog self.usage = usage self.epilog = epilog - self.version = version self.formatter_class = formatter_class self.fromfile_prefix_chars = fromfile_prefix_chars self.add_help = add_help @@ -1624,7 +1614,7 @@ return string self.register('type', None, identity) - # add help and version arguments if necessary + # add help argument if necessary # (using explicit default to override global argument_default) default_prefix = '-' if '-' in prefix_chars else prefix_chars[0] if self.add_help: @@ -1632,12 +1622,6 @@ default_prefix+'h', default_prefix*2+'help', action='help', default=SUPPRESS, help=_('show this help message and exit')) - if self.version: - self.add_argument( - default_prefix+'v', default_prefix*2+'version', - action='version', default=SUPPRESS, - version=self.version, - help=_("show program's version number and exit")) # add parent arguments and defaults for parent in parents: @@ -1657,7 +1641,6 @@ 'prog', 'usage', 'description', - 'version', 'formatter_class', 'conflict_handler', 'add_help', @@ -2320,16 +2303,6 @@ # determine help from format above return formatter.format_help() - def format_version(self): - import warnings - warnings.warn( - 'The format_version method is deprecated -- the "version" ' - 'argument to ArgumentParser is no longer supported.', - DeprecationWarning) - formatter = self._get_formatter() - formatter.add_text(self.version) - return formatter.format_help() - def _get_formatter(self): return self.formatter_class(prog=self.prog) @@ -2346,14 +2319,6 @@ file = _sys.stdout self._print_message(self.format_help(), file) - def print_version(self, file=None): - import warnings - warnings.warn( - 'The print_version method is deprecated -- the "version" ' - 'argument to ArgumentParser is no longer supported.', - DeprecationWarning) - self._print_message(self.format_version(), file) - def _print_message(self, message, file=None): if message: if file is None: diff --git a/Lib/asyncore.py b/Lib/asyncore.py --- a/Lib/asyncore.py +++ b/Lib/asyncore.py @@ -50,7 +50,6 @@ import socket import sys import time -import warnings import os from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \ @@ -399,20 +398,6 @@ if why.args[0] not in (ENOTCONN, EBADF): raise - # cheap inheritance, used to pass all other attribute - # references to the underlying socket object. - def __getattr__(self, attr): - try: - retattr = getattr(self.socket, attr) - except AttributeError: - raise AttributeError("%s instance has no attribute '%s'" - %(self.__class__.__name__, attr)) - else: - msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s " \ - "instead" % {'me' : self.__class__.__name__, 'attr' : attr} - warnings.warn(msg, DeprecationWarning, stacklevel=2) - return retattr - # log and log_info may be overridden to provide more sophisticated # logging and warning methods. In general, log is for 'hit' logging # and 'log_info' is for informational, warning and error logging. diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -345,13 +345,6 @@ pieces.append(binascii.b2a_base64(chunk)) return b"".join(pieces) -def encodestring(s): - """Legacy alias of encodebytes().""" - import warnings - warnings.warn("encodestring() is a deprecated alias, use encodebytes()", - DeprecationWarning, 2) - return encodebytes(s) - def decodebytes(s): """Decode a bytestring of base-64 data into a bytestring.""" @@ -359,13 +352,6 @@ raise TypeError("expected bytes, not %s" % s.__class__.__name__) return binascii.a2b_base64(s) -def decodestring(s): - """Legacy alias of decodebytes().""" - import warnings - warnings.warn("decodestring() is a deprecated alias, use decodebytes()", - DeprecationWarning, 2) - return decodebytes(s) - # Usable as a script... def main(): diff --git a/Lib/cgi.py b/Lib/cgi.py --- a/Lib/cgi.py +++ b/Lib/cgi.py @@ -42,7 +42,7 @@ import tempfile __all__ = ["MiniFieldStorage", "FieldStorage", - "parse", "parse_qs", "parse_qsl", "parse_multipart", + "parse", "parse_multipart", "parse_header", "print_exception", "print_environ", "print_form", "print_directory", "print_arguments", "print_environ_usage", "escape"] @@ -181,21 +181,6 @@ encoding=encoding) -# parse query string function called from urlparse, -# this is done in order to maintain backward compatiblity. - -def parse_qs(qs, keep_blank_values=0, strict_parsing=0): - """Parse a query given as a string argument.""" - warn("cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead", - DeprecationWarning, 2) - return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing) - -def parse_qsl(qs, keep_blank_values=0, strict_parsing=0): - """Parse a query given as a string argument.""" - warn("cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl instead", - DeprecationWarning, 2) - return urllib.parse.parse_qsl(qs, keep_blank_values, strict_parsing) - def parse_multipart(fp, pdict): """Parse multipart input. diff --git a/Lib/gzip.py b/Lib/gzip.py --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -183,14 +183,6 @@ if self.mode == WRITE: self._write_gzip_header() - @property - def filename(self): - import warnings - warnings.warn("use the name attribute", DeprecationWarning, 2) - if self.mode == WRITE and self.name[-3:] != ".gz": - return self.name + ".gz" - return self.name - def __repr__(self): fileobj = self.fileobj if isinstance(fileobj, _PaddedFile): diff --git a/Lib/http/client.py b/Lib/http/client.py --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -73,7 +73,6 @@ import socket import collections from urllib.parse import urlsplit -import warnings __all__ = ["HTTPResponse", "HTTPConnection", "HTTPException", "NotConnected", "UnknownProtocol", @@ -259,8 +258,6 @@ return email.parser.Parser(_class=_class).parsestr(hstring) -_strict_sentinel = object() - class HTTPResponse(io.RawIOBase): # See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details. @@ -270,7 +267,7 @@ # text following RFC 2047. The basic status line parsing only # accepts iso-8859-1. - def __init__(self, sock, debuglevel=0, strict=_strict_sentinel, method=None, url=None): + def __init__(self, sock, debuglevel=0, method=None, url=None): # If the response includes a content-length header, we need to # make sure that the client doesn't read more than the # specified number of bytes. If it does, it will block until @@ -280,10 +277,6 @@ # clients unless they know what they are doing. self.fp = sock.makefile("rb") self.debuglevel = debuglevel - if strict is not _strict_sentinel: - warnings.warn("the 'strict' argument isn't supported anymore; " - "http.client now always assumes HTTP/1.x compliant servers.", - DeprecationWarning, 2) self._method = method # The HTTPResponse object is returned via urllib. The clients @@ -709,12 +702,8 @@ auto_open = 1 debuglevel = 0 - def __init__(self, host, port=None, strict=_strict_sentinel, + def __init__(self, host, port=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None): - if strict is not _strict_sentinel: - warnings.warn("the 'strict' argument isn't supported anymore; " - "http.client now always assumes HTTP/1.x compliant servers.", - DeprecationWarning, 2) self.timeout = timeout self.source_address = source_address self.sock = None @@ -1143,9 +1132,9 @@ # XXX Should key_file and cert_file be deprecated in favour of context? def __init__(self, host, port=None, key_file=None, cert_file=None, - strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, + timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, *, context=None, check_hostname=None): - super(HTTPSConnection, self).__init__(host, port, strict, timeout, + super(HTTPSConnection, self).__init__(host, port, timeout, source_address) self.key_file = key_file self.cert_file = cert_file diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py --- a/Lib/lib2to3/pytree.py +++ b/Lib/lib2to3/pytree.py @@ -13,7 +13,6 @@ __author__ = "Guido van Rossum " import sys -import warnings from io import StringIO HUGE = 0x7FFFFFFF # maximum repeat count, default max @@ -109,26 +108,6 @@ """ raise NotImplementedError - def set_prefix(self, prefix): - """ - Set the prefix for the node (see Leaf class). - - DEPRECATED; use the prefix property directly. - """ - warnings.warn("set_prefix() is deprecated; use the prefix property", - DeprecationWarning, stacklevel=2) - self.prefix = prefix - - def get_prefix(self): - """ - Return the prefix for the node (see Leaf class). - - DEPRECATED; use the prefix property directly. - """ - warnings.warn("get_prefix() is deprecated; use the prefix property", - DeprecationWarning, stacklevel=2) - return self.prefix - def replace(self, new): """Replace this node with a new one in the parent.""" assert self.parent is not None, str(self) diff --git a/Lib/lib2to3/tests/test_pytree.py b/Lib/lib2to3/tests/test_pytree.py --- a/Lib/lib2to3/tests/test_pytree.py +++ b/Lib/lib2to3/tests/test_pytree.py @@ -31,22 +31,10 @@ """Unit tests for nodes (Base, Leaf, Node).""" - if sys.version_info >= (2,6): - # warnings.catch_warnings is new in 2.6. - def test_deprecated_prefix_methods(self): - l = pytree.Leaf(100, "foo") - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always", DeprecationWarning) - self.assertEqual(l.get_prefix(), "") - l.set_prefix("hi") - self.assertEqual(l.prefix, "hi") - self.assertEqual(len(w), 2) - for warning in w: - self.assertTrue(warning.category is DeprecationWarning) - self.assertEqual(str(w[0].message), "get_prefix() is deprecated; " \ - "use the prefix property") - self.assertEqual(str(w[1].message), "set_prefix() is deprecated; " \ - "use the prefix property") + # warnings.catch_warnings is new in 2.6. + def test_removed_prefix_methods(self): + self.assertRaises(AttributeError, getattr, self, 'get_prefix') + self.assertRaises(AttributeError, getattr, self, 'set_prefix') def test_instantiate_base(self): if __debug__: diff --git a/Lib/mailbox.py b/Lib/mailbox.py --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -15,7 +15,6 @@ import socket import errno import copy -import warnings import email import email.message import email.generator @@ -221,9 +220,7 @@ target.write(data) elif isinstance(message, (str, bytes, io.StringIO)): if isinstance(message, io.StringIO): - warnings.warn("Use of StringIO input is deprecated, " - "use BytesIO instead", DeprecationWarning, 3) - message = message.getvalue() + raise TypeError("Use BytesIO instead of StringIO") if isinstance(message, str): message = self._string_to_bytes(message) if mangle_from_: @@ -232,9 +229,7 @@ target.write(message) elif hasattr(message, 'read'): if hasattr(message, 'buffer'): - warnings.warn("Use of text mode files is deprecated, " - "use a binary mode file instead", DeprecationWarning, 3) - message = message.buffer + raise TypeError("Use binary mode instead of text mode file") while True: line = message.readline() # Universal newline support. @@ -1391,9 +1386,7 @@ self._file.write(buffer.replace(b'\n', linesep)) elif isinstance(message, (bytes, str, io.StringIO)): if isinstance(message, io.StringIO): - warnings.warn("Use of StringIO input is deprecated, " - "use BytesIO instead", DeprecationWarning, 3) - message = message.getvalue() + raise TypeError("Use BytesIO instead of StringIO") if isinstance(message, str): message = self._string_to_bytes(message) body_start = message.find(b'\n\n') + 2 @@ -1407,9 +1400,7 @@ self._file.write(message.replace(b'\n', linesep)) elif hasattr(message, 'readline'): if hasattr(message, 'buffer'): - warnings.warn("Use of text mode files is deprecated, " - "use a binary mode file instead", DeprecationWarning, 3) - message = message.buffer + raise TypeError("Use binary mode instead of text mode file") original_pos = message.tell() first_pass = True while True: diff --git a/Lib/ntpath.py b/Lib/ntpath.py --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -15,7 +15,7 @@ "basename","dirname","commonprefix","getsize","getmtime", "getatime","getctime", "islink","exists","lexists","isdir","isfile", "ismount", "expanduser","expandvars","normpath","abspath", - "splitunc","curdir","pardir","sep","pathsep","defpath","altsep", + "curdir","pardir","sep","pathsep","defpath","altsep", "extsep","devnull","realpath","supports_unicode_filenames","relpath", "samefile", "sameopenfile",] @@ -229,42 +229,6 @@ return empty, p -# Parse UNC paths -def splitunc(p): - """Deprecated since Python 3.1. Please use splitdrive() instead; - it now handles UNC paths. - - Split a pathname into UNC mount point and relative path specifiers. - - Return a 2-tuple (unc, rest); either part may be empty. - If unc is not empty, it has the form '//host/mount' (or similar - using backslashes). unc+rest is always the input path. - Paths containing drive letters never have an UNC part. - """ - import warnings - warnings.warn("ntpath.splitunc is deprecated, use ntpath.splitdrive instead", - DeprecationWarning) - sep = _get_sep(p) - if not p[1:2]: - return p[:0], p # Drive letter present - firstTwo = p[0:2] - if normcase(firstTwo) == sep + sep: - # is a UNC path: - # vvvvvvvvvvvvvvvvvvvv equivalent to drive letter - # \\machine\mountpoint\directories... - # directory ^^^^^^^^^^^^^^^ - normp = normcase(p) - index = normp.find(sep, 2) - if index == -1: - ##raise RuntimeError, 'illegal UNC path: "' + p + '"' - return (p[:0], p) - index = normp.find(sep, index + 1) - if index == -1: - index = len(p) - return p[:index], p[index:] - return p[:0], p - - # Split a path in head (everything up to the last '/') and tail (the # rest). After the trailing '/' is stripped, the invariant # join(head, tail) == p holds. diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py --- a/Lib/packaging/util.py +++ b/Lib/packaging/util.py @@ -1002,6 +1002,8 @@ config = RawConfigParser() f = codecs.open(path, encoding='utf-8') try: + config.read_file(f) + except AttributeError: config.readfp(f) finally: f.close() diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2018,31 +2018,21 @@ print("link to", tarinfo.linkname, end=' ') print() - def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None): + def add(self, name, arcname=None, recursive=True, *, filter=None): """Add the file `name' to the archive. `name' may be any type of file (directory, fifo, symbolic link, etc.). If given, `arcname' specifies an alternative name for the file in the archive. Directories are added recursively by default. This can be avoided by - setting `recursive' to False. `exclude' is a function that should - return True for each filename to be excluded. `filter' is a function - that expects a TarInfo object argument and returns the changed - TarInfo object, if it returns None the TarInfo object will be - excluded from the archive. + setting `recursive' to False. `filter' is a function that expects a + TarInfo object argument and returns the changed TarInfo object, if + it returns None the TarInfo object will be excluded + from the archive. """ self._check("aw") if arcname is None: arcname = name - # Exclude pathnames. - if exclude is not None: - import warnings - warnings.warn("use the filter argument instead", - DeprecationWarning, 2) - if exclude(name): - self._dbg(2, "tarfile: Excluded %r" % name) - return - # Skip if somebody tries to archive the archive... if self.name is not None and os.path.abspath(name) == self.name: self._dbg(2, "tarfile: Skipped %r" % name) @@ -2075,7 +2065,7 @@ if recursive: for f in os.listdir(name): self.add(os.path.join(name, f), os.path.join(arcname, f), - recursive, exclude, filter=filter) + recursive, filter=filter) else: self.addfile(tarinfo) diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -1323,20 +1323,21 @@ class TestParserDefault42(ParserTestCase): """Test actions with a parser-level default of 42""" - parser_signature = Sig(argument_default=42, version='1.0') + parser_signature = Sig(argument_default=42) argument_signatures = [ + Sig('--version', action='version', version='1.0'), Sig('foo', nargs='?'), Sig('bar', nargs='*'), Sig('--baz', action='store_true'), ] failures = ['-x'] successes = [ - ('', NS(foo=42, bar=42, baz=42)), - ('a', NS(foo='a', bar=42, baz=42)), - ('a b', NS(foo='a', bar=['b'], baz=42)), - ('--baz', NS(foo=42, bar=42, baz=True)), - ('a --baz', NS(foo='a', bar=42, baz=True)), - ('--baz a b', NS(foo='a', bar=['b'], baz=True)), + ('', NS(foo=42, bar=42, baz=42, version=42)), + ('a', NS(foo='a', bar=42, baz=42, version=42)), + ('a b', NS(foo='a', bar=['b'], baz=42, version=42)), + ('--baz', NS(foo=42, bar=42, baz=True, version=42)), + ('a --baz', NS(foo='a', bar=42, baz=True, version=42)), + ('--baz a b', NS(foo='a', bar=['b'], baz=True, version=42)), ] @@ -2894,10 +2895,9 @@ parser_text = sfile.getvalue() self._test(tester, parser_text) - # add tests for {format,print}_{usage,help,version} + # add tests for {format,print}_{usage,help} for func_suffix, std_name in [('usage', 'stdout'), - ('help', 'stdout'), - ('version', 'stderr')]: + ('help', 'stdout')]: AddTests(cls, func_suffix, std_name) bases = TestCase, @@ -2908,8 +2908,9 @@ """Make sure that argument help aligns when options are longer""" parser_signature = Sig(prog='PROG', description='DESCRIPTION', - epilog='EPILOG', version='0.1') + epilog='EPILOG') argument_signatures = [ + Sig('-v', '--version', action='version', version='0.1'), Sig('-x', action='store_true', help='X HELP'), Sig('--y', help='Y HELP'), Sig('foo', help='FOO HELP'), @@ -2944,8 +2945,9 @@ """Make sure that argument help aligns when options are longer""" parser_signature = Sig(prog='PROG', description='DESCRIPTION', - epilog='EPILOG', version='0.1') + epilog='EPILOG') argument_signatures = [ + Sig('-v', '--version', action='version', version='0.1'), Sig('-x', action='store_true', help='X HELP'), Sig('--y', help='Y HELP'), Sig('foo', help='FOO HELP'), @@ -3112,9 +3114,9 @@ class TestHelpWrappingLongNames(HelpTestCase): """Make sure that text after long names starts on the next line""" - parser_signature = Sig(usage='USAGE', description= 'D D' * 30, - version='V V'*30) + parser_signature = Sig(usage='USAGE', description= 'D D' * 30) argument_signatures = [ + Sig('-v', '--version', action='version', version='V V' * 30), Sig('-x', metavar='X' * 25, help='XH XH' * 20), Sig('y', metavar='y' * 25, help='YH YH' * 20), ] @@ -3717,8 +3719,9 @@ class TestHelpVersionOptional(HelpTestCase): """Test that the --version argument can be suppressed help messages""" - parser_signature = Sig(prog='PROG', version='1.0') + parser_signature = Sig(prog='PROG') argument_signatures = [ + Sig('-v', '--version', action='version', version='1.0'), Sig('--foo', help='foo help'), Sig('spam', help='spam help'), ] @@ -3951,8 +3954,8 @@ class TestHelpSubparsersOrdering(HelpTestCase): """Test ordering of subcommands in help matches the code""" parser_signature = Sig(prog='PROG', - description='display some subcommands', - version='0.1') + description='display some subcommands') + argument_signatures = [Sig('-v', '--version', action='version', version='0.1')] subparsers_signatures = [Sig(name=name) for name in ('a', 'b', 'c', 'd', 'e')] @@ -3980,8 +3983,8 @@ class TestHelpSubparsersWithHelpOrdering(HelpTestCase): """Test ordering of subcommands in help matches the code""" parser_signature = Sig(prog='PROG', - description='display some subcommands', - version='0.1') + description='display some subcommands') + argument_signatures = [Sig('-v', '--version', action='version', version='0.1')] subcommand_data = (('a', 'a subcommand help'), ('b', 'b subcommand help'), @@ -4279,27 +4282,29 @@ self._get_error(parser.parse_args, args_str.split()).stdout) def assertPrintVersionExit(self, parser, args_str): - self.assertEqual( - parser.format_version(), - self._get_error(parser.parse_args, args_str.split()).stderr) + # XXX + self.assertRaises(AttributeError, getattr, parser, 'format_version') def assertArgumentParserError(self, parser, *args): self.assertRaises(ArgumentParserError, parser.parse_args, args) def test_version(self): - parser = ErrorRaisingArgumentParser(version='1.0') + parser = ErrorRaisingArgumentParser() + parser.add_argument('-v', '--version', action='version', version='1.0') self.assertPrintHelpExit(parser, '-h') self.assertPrintHelpExit(parser, '--help') self.assertPrintVersionExit(parser, '-v') self.assertPrintVersionExit(parser, '--version') def test_version_format(self): - parser = ErrorRaisingArgumentParser(prog='PPP', version='%(prog)s 3.5') + parser = ErrorRaisingArgumentParser(prog='PPP') + parser.add_argument('-v', '--version', action='version', version='%(prog)s 3.5') msg = self._get_error(parser.parse_args, ['-v']).stderr self.assertEqual('PPP 3.5\n', msg) def test_version_no_help(self): - parser = ErrorRaisingArgumentParser(add_help=False, version='1.0') + parser = ErrorRaisingArgumentParser(add_help=False) + parser.add_argument('-v', '--version', action='version', version='1.0') self.assertArgumentParserError(parser, '-h') self.assertArgumentParserError(parser, '--help') self.assertPrintVersionExit(parser, '-v') @@ -4328,7 +4333,8 @@ self.assertArgumentParserError(parser, '--version') def test_help_version_extra_arguments(self): - parser = ErrorRaisingArgumentParser(version='1.0') + parser = ErrorRaisingArgumentParser() + parser.add_argument('--version', action='version', version='1.0') parser.add_argument('-x', action='store_true') parser.add_argument('y') @@ -4396,7 +4402,7 @@ parser = argparse.ArgumentParser(prog='PROG') string = ( "ArgumentParser(prog='PROG', usage=None, description=None, " - "version=None, formatter_class=%r, conflict_handler='error', " + "formatter_class=%r, conflict_handler='error', " "add_help=True)" % argparse.HelpFormatter) self.assertStringEqual(parser, string) @@ -4758,13 +4764,7 @@ self.assertEqual(sorted(items), sorted(argparse.__all__)) def test_main(): - # silence warnings about version argument - these are expected - with support.check_warnings( - ('The "version" argument to ArgumentParser is deprecated.', - DeprecationWarning), - ('The (format|print)_version method is deprecated', - DeprecationWarning)): - support.run_unittest(__name__) + support.run_unittest(__name__) # Remove global references to avoid looking like we have refleaks. RFile.seen = {} WFile.seen = set() diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -321,16 +321,10 @@ d = asyncore.dispatcher(socket.socket()) # make sure the error message no longer refers to the socket # object but the dispatcher instance instead - self.assertRaisesRegex(AttributeError, 'dispatcher instance', + self.assertRaisesRegex(AttributeError, "'dispatcher' object has no attribute 'foo'", getattr, d, 'foo') - # cheap inheritance with the underlying socket is supposed - # to still work but a DeprecationWarning is expected - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - family = d.family - self.assertEqual(family, socket.AF_INET) - self.assertEqual(len(w), 1) - self.assertTrue(issubclass(w[0].category, DeprecationWarning)) + # cheap inheritance with the underlying socket no longer works + self.assertRaises(AttributeError, getattr, d, 'family') def test_strerror(self): # refers to bug #8573 diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1374,17 +1374,11 @@ # -------------------------------------------------------------------- # Issue #7994: object.__format__ with a non-empty format string is # deprecated - def test_deprecated_format_string(obj, fmt_str, should_raise_warning): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always", DeprecationWarning) + def test_deprecated_format_string(obj, fmt_str, should_raise): + if should_raise: + self.assertRaises(TypeError, format, obj, fmt_str) + else: format(obj, fmt_str) - if should_raise_warning: - self.assertEqual(len(w), 1) - self.assertIsInstance(w[0].message, DeprecationWarning) - self.assertIn('object.__format__ with a non-empty format ' - 'string', str(w[0].message)) - else: - self.assertEqual(len(w), 0) fmt_strs = ['', 's'] diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -303,19 +303,10 @@ v = gen_result(data, environ) self.assertEqual(result, v) - def test_deprecated_parse_qs(self): - # this func is moved to urllib.parse, this is just a sanity check - with check_warnings(('cgi.parse_qs is deprecated, use urllib.parse.' - 'parse_qs instead', DeprecationWarning)): - self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']}, - cgi.parse_qs('a=A1&b=B2&B=B3')) - - def test_deprecated_parse_qsl(self): - # this func is moved to urllib.parse, this is just a sanity check - with check_warnings(('cgi.parse_qsl is deprecated, use urllib.parse.' - 'parse_qsl instead', DeprecationWarning)): - self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')], - cgi.parse_qsl('a=A1&b=B2&B=B3')) + def test_moved_functions(self): + # these funcs are moved to urllib.parse, this is just a sanity check + self.assertRaises(AttributeError, getattr, cgi, 'parse_qs') + self.assertRaises(AttributeError, getattr, cgi, 'parse_qsl') def test_parse_header(self): self.assertEqual( diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1236,9 +1236,8 @@ self.assertRaises(IOError, bufio.tell) self.assertRaises(IOError, bufio.write, b"abcdef") - def test_max_buffer_size_deprecation(self): - with support.check_warnings(("max_buffer_size is deprecated", - DeprecationWarning)): + def test_max_buffer_size_removal(self): + with self.assertRaises(TypeError): self.tp(self.MockRawIO(), 8, 12) @@ -1294,9 +1293,8 @@ pair = self.tp(self.MockRawIO(), self.MockRawIO()) self.assertRaises(self.UnsupportedOperation, pair.detach) - def test_constructor_max_buffer_size_deprecation(self): - with support.check_warnings(("max_buffer_size is deprecated", - DeprecationWarning)): + def test_constructor_max_buffer_size_removal(self): + with self.assertRaises(TypeError): self.tp(self.MockRawIO(), self.MockRawIO(), 8, 12) def test_constructor_with_not_readable(self): diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -79,12 +79,11 @@ self.assertEqual(len(self._box), 5) keys.append(self._box.add(_bytes_sample_message)) self.assertEqual(len(self._box), 6) - with self.assertWarns(DeprecationWarning): - keys.append(self._box.add( - io.TextIOWrapper(io.BytesIO(_bytes_sample_message)))) - self.assertEqual(len(self._box), 7) + self.assertRaises(TypeError, self._box.add, + io.TextIOWrapper(io.BytesIO(_bytes_sample_message))) + self.assertEqual(len(self._box), 6) self.assertEqual(self._box.get_string(keys[0]), self._template % 0) - for i in (1, 2, 3, 4, 5, 6): + for i in (1, 2, 3, 4, 5): self._check_sample(self._box[keys[i]]) _nonascii_msg = textwrap.dedent("""\ @@ -167,26 +166,15 @@ self.assertEqual(self._box.get_bytes(key).split(b'\n'), self._non_latin_bin_msg.split(b'\n')) - def test_add_text_file_warns(self): + def test_add_text_file_raises(self): with tempfile.TemporaryFile('w+') as f: f.write(_sample_message) f.seek(0) - with self.assertWarns(DeprecationWarning): - key = self._box.add(f) - # See issue 11062 - if not isinstance(self._box, mailbox.Babyl): - self.assertEqual(self._box.get_bytes(key).split(b'\n'), - _bytes_sample_message.split(b'\n')) + self.assertRaises(TypeError, self._box.add, f) - def test_add_StringIO_warns(self): - with self.assertWarns(DeprecationWarning): - key = self._box.add(io.StringIO(self._template % "0")) - self.assertEqual(self._box.get_string(key), self._template % "0") - - def test_add_nonascii_StringIO_raises(self): - with self.assertWarns(DeprecationWarning): - with self.assertRaisesRegex(ValueError, "ASCII-only"): - self._box.add(io.StringIO(self._nonascii_msg)) + def test_add_StringIO_raises(self): + self.assertRaises(TypeError, self._box.add, io.StringIO(self._template % "0")) + self.assertRaises(TypeError, self._box.add, io.StringIO(self._nonascii_msg)) self.assertEqual(len(self._box), 0) self._box.close() self.assertMailboxEmpty() diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -259,7 +259,7 @@ class NtCommonTest(test_genericpath.CommonTest): pathmodule = ntpath - attributes = ['relpath', 'splitunc'] + attributes = ['relpath'] def test_main(): diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -3,7 +3,6 @@ import struct import subprocess import textwrap -import warnings import operator import codecs @@ -182,13 +181,8 @@ # testing sys.setprofile() is done in test_sys_setprofile.py def test_setcheckinterval(self): - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - self.assertRaises(TypeError, sys.setcheckinterval) - orig = sys.getcheckinterval() - for n in 0, 100, 120, orig: # orig last to restore starting state - sys.setcheckinterval(n) - self.assertEqual(sys.getcheckinterval(), n) + self.assertRaises(AttributeError, getattr, sys, 'getcheckinterval') + self.assertRaises(AttributeError, getattr, sys, 'setcheckinterval') @unittest.skipUnless(threading, 'Threading required for this test.') def test_switchinterval(self): diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -927,33 +927,6 @@ finally: tar.close() - def test_exclude(self): - tempdir = os.path.join(TEMPDIR, "exclude") - os.mkdir(tempdir) - try: - for name in ("foo", "bar", "baz"): - name = os.path.join(tempdir, name) - support.create_empty_file(name) - - exclude = os.path.isfile - - tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1") - try: - with support.check_warnings(("use the filter argument", - DeprecationWarning)): - tar.add(tempdir, arcname="empty_dir", exclude=exclude) - finally: - tar.close() - - tar = tarfile.open(tmpname, "r") - try: - self.assertEqual(len(tar.getmembers()), 1) - self.assertEqual(tar.getnames()[0], "empty_dir") - finally: - tar.close() - finally: - shutil.rmtree(tempdir) - def test_filter(self): tempdir = os.path.join(TEMPDIR, "filter") os.mkdir(tempdir) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -789,11 +789,9 @@ self.assertEqual('{0:d}'.format(G('data')), 'G(data)') self.assertEqual('{0!s}'.format(G('data')), 'string is data') - msg = 'object.__format__ with a non-empty format string is deprecated' - with support.check_warnings((msg, DeprecationWarning)): - self.assertEqual('{0:^10}'.format(E('data')), ' E(data) ') - self.assertEqual('{0:^10s}'.format(E('data')), ' E(data) ') - self.assertEqual('{0:>15s}'.format(G('data')), ' string is data') + self.assertRaises(TypeError, '{0:^10}'.format, E('data')) + self.assertRaises(TypeError, '{0:^10s}'.format, E('data')) + self.assertRaises(TypeError, '{0:>15s}'.format, G('data')) self.assertEqual("{0:date: %Y-%m-%d}".format(I(year=2007, month=8, diff --git a/Lib/trace.py b/Lib/trace.py --- a/Lib/trace.py +++ b/Lib/trace.py @@ -60,7 +60,6 @@ import gc import dis import pickle -from warnings import warn as _warn try: import threading @@ -811,47 +810,6 @@ if not no_report: results.write_results(missing, summary=summary, coverdir=coverdir) -# Deprecated API -def usage(outfile): - _warn("The trace.usage() function is deprecated", - DeprecationWarning, 2) - _usage(outfile) - -class Ignore(_Ignore): - def __init__(self, modules=None, dirs=None): - _warn("The class trace.Ignore is deprecated", - DeprecationWarning, 2) - _Ignore.__init__(self, modules, dirs) - -def modname(path): - _warn("The trace.modname() function is deprecated", - DeprecationWarning, 2) - return _modname(path) - -def fullmodname(path): - _warn("The trace.fullmodname() function is deprecated", - DeprecationWarning, 2) - return _fullmodname(path) - -def find_lines_from_code(code, strs): - _warn("The trace.find_lines_from_code() function is deprecated", - DeprecationWarning, 2) - return _find_lines_from_code(code, strs) - -def find_lines(code, strs): - _warn("The trace.find_lines() function is deprecated", - DeprecationWarning, 2) - return _find_lines(code, strs) - -def find_strings(filename, encoding=None): - _warn("The trace.find_strings() function is deprecated", - DeprecationWarning, 2) - return _find_strings(filename, encoding=None) - -def find_executable_linenos(filename): - _warn("The trace.find_executable_linenos() function is deprecated", - DeprecationWarning, 2) - return _find_executable_linenos(filename) if __name__=='__main__': main() diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1744,15 +1744,6 @@ -static int -complain_about_max_buffer_size(void) -{ - if (PyErr_WarnEx(PyExc_DeprecationWarning, - "max_buffer_size is deprecated", 1) < 0) - return 0; - return 1; -} - /* * class BufferedWriter */ @@ -1761,7 +1752,7 @@ "\n" "The constructor creates a BufferedWriter for the given writeable raw\n" "stream. If the buffer_size is not given, it defaults to\n" - "DEFAULT_BUFFER_SIZE. max_buffer_size isn't used anymore.\n" + "DEFAULT_BUFFER_SIZE.\n" ); static void @@ -1774,23 +1765,18 @@ static int bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds) { - /* TODO: properly deprecate max_buffer_size */ - char *kwlist[] = {"raw", "buffer_size", "max_buffer_size", NULL}; + char *kwlist[] = {"raw", "buffer_size", NULL}; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - Py_ssize_t max_buffer_size = -234; PyObject *raw; self->ok = 0; self->detached = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedReader", kwlist, - &raw, &buffer_size, &max_buffer_size)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedReader", kwlist, + &raw, &buffer_size)) { return -1; } - if (max_buffer_size != -234 && !complain_about_max_buffer_size()) - return -1; - if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; @@ -2171,16 +2157,12 @@ { PyObject *reader, *writer; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - Py_ssize_t max_buffer_size = -234; - if (!PyArg_ParseTuple(args, "OO|nn:BufferedRWPair", &reader, &writer, - &buffer_size, &max_buffer_size)) { + if (!PyArg_ParseTuple(args, "OO|n:BufferedRWPair", &reader, &writer, + &buffer_size)) { return -1; } - if (max_buffer_size != -234 && !complain_about_max_buffer_size()) - return -1; - if (_PyIOBase_check_readable(reader, Py_True) == NULL) return -1; if (_PyIOBase_check_writable(writer, Py_True) == NULL) @@ -2405,28 +2387,24 @@ "\n" "The constructor creates a reader and writer for a seekable stream,\n" "raw, given in the first argument. If the buffer_size is omitted it\n" - "defaults to DEFAULT_BUFFER_SIZE. max_buffer_size isn't used anymore.\n" + "defaults to DEFAULT_BUFFER_SIZE.\n" ); static int bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds) { - char *kwlist[] = {"raw", "buffer_size", "max_buffer_size", NULL}; + char *kwlist[] = {"raw", "buffer_size", NULL}; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; - Py_ssize_t max_buffer_size = -234; PyObject *raw; self->ok = 0; self->detached = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|nn:BufferedReader", kwlist, - &raw, &buffer_size, &max_buffer_size)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedReader", kwlist, + &raw, &buffer_size)) { return -1; } - if (max_buffer_size != -234 && !complain_about_max_buffer_size()) - return -1; - if (_PyIOBase_check_seekable(raw, Py_True) == NULL) return -1; if (_PyIOBase_check_readable(raw, Py_True) == NULL) diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2919,9 +2919,9 @@ if (type->tp_init != object_init && type->tp_new != object_new) { - err = PyErr_WarnEx(PyExc_DeprecationWarning, - "object.__init__() takes no parameters", - 1); + PyErr_SetString(PyExc_TypeError, + "object.__init__() takes no parameters"); + err = -1; } else if (type->tp_init != object_init || type->tp_new == object_new) @@ -2942,9 +2942,9 @@ if (type->tp_new != object_new && type->tp_init != object_init) { - err = PyErr_WarnEx(PyExc_DeprecationWarning, - "object.__new__() takes no parameters", - 1); + PyErr_SetString(PyExc_TypeError, + "object.__new__() takes no parameters"); + err = -1; } else if (type->tp_new != object_new || type->tp_init == object_init) @@ -3561,16 +3561,9 @@ /* Issue 7994: If we're converting to a string, we should reject format specifications */ if (PyUnicode_GET_LENGTH(format_spec) > 0) { - if (PyErr_WarnEx(PyExc_DeprecationWarning, - "object.__format__ with a non-empty format " - "string is deprecated", 1) < 0) { - goto done; - } - /* Eventually this will become an error: - PyErr_Format(PyExc_TypeError, + PyErr_SetString(PyExc_TypeError, "non-empty format string passed to object.__format__"); - goto done; - */ + goto done; } result = PyObject_Format(self_as_str, format_spec); @@ -4199,13 +4192,11 @@ /* Warn for a type that implements tp_compare (now known as tp_reserved) but not tp_richcompare. */ if (type->tp_reserved && !type->tp_richcompare) { - int error; - error = PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + PyErr_Format(PyExc_TypeError, "Type %.100s defines tp_reserved (formerly tp_compare) " "but not tp_richcompare. Comparisons may not behave as intended.", type->tp_name); - if (error == -1) - goto error; + goto error; } /* All done -- set the ready flag */ diff --git a/Python/sysmodule.c b/Python/sysmodule.c --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -489,44 +489,6 @@ See the profiler chapter in the library manual." ); -static int _check_interval = 100; - -static PyObject * -sys_setcheckinterval(PyObject *self, PyObject *args) -{ - if (PyErr_WarnEx(PyExc_DeprecationWarning, - "sys.getcheckinterval() and sys.setcheckinterval() " - "are deprecated. Use sys.setswitchinterval() " - "instead.", 1) < 0) - return NULL; - if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval)) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -PyDoc_STRVAR(setcheckinterval_doc, -"setcheckinterval(n)\n\ -\n\ -Tell the Python interpreter to check for asynchronous events every\n\ -n instructions. This also affects how often thread switches occur." -); - -static PyObject * -sys_getcheckinterval(PyObject *self, PyObject *args) -{ - if (PyErr_WarnEx(PyExc_DeprecationWarning, - "sys.getcheckinterval() and sys.setcheckinterval() " - "are deprecated. Use sys.getswitchinterval() " - "instead.", 1) < 0) - return NULL; - return PyLong_FromLong(_check_interval); -} - -PyDoc_STRVAR(getcheckinterval_doc, -"getcheckinterval() -> current check interval; see setcheckinterval()." -); - #ifdef WITH_THREAD static PyObject * sys_setswitchinterval(PyObject *self, PyObject *args) @@ -1069,10 +1031,6 @@ #ifdef USE_MALLOPT {"mdebug", sys_mdebug, METH_VARARGS}, #endif - {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, - setcheckinterval_doc}, - {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, - getcheckinterval_doc}, #ifdef WITH_THREAD {"setswitchinterval", sys_setswitchinterval, METH_VARARGS, setswitchinterval_doc}, @@ -1298,7 +1256,6 @@ getrecursionlimit() -- return the max recursion depth for the interpreter\n\ getsizeof() -- return the size of an object in bytes\n\ gettrace() -- get the global debug tracing function\n\ -setcheckinterval() -- control how often the interpreter checks for events\n\ setdlopenflags() -- set the flags to be used for dlopen() calls\n\ setprofile() -- set the global profiling function\n\ setrecursionlimit() -- set the max recursion depth for the interpreter\n\