cpython/Lib
Robert Smallshire 58a7da9e12
bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121)
* bpo-26680: Adds support for int.is_integer() for compatibility with float.is_integer().

The int.is_integer() method always returns True.

* bpo-26680: Adds a test to ensure that False.is_integer() and True.is_integer() are always True.

* bpo-26680: Adds Real.is_integer() with a trivial implementation using conversion to int.

This default implementation is intended to reduce the workload for subclass
implementers. It is not robust in the presence of infinities or NaNs and
may have suboptimal performance for other types.

* bpo-26680: Adds Rational.is_integer which returns True if the denominator is one.

This implementation assumes the Rational is represented in it's
lowest form, as required by the class docstring.

* bpo-26680: Adds Integral.is_integer which always returns True.

* bpo-26680: Adds tests for Fraction.is_integer called as an instance method.

The tests for the Rational abstract base class use an unbound
method to sidestep the inability to directly instantiate Rational.
These tests check that everything works correct as an instance method.

* bpo-26680: Updates documentation for Real.is_integer and built-ins int and float.

The call x.is_integer() is now listed in the table of operations
which apply to all numeric types except complex, with a reference
to the full documentation for Real.is_integer().  Mention of
is_integer() has been removed from the section 'Additional Methods
on Float'.

The documentation for Real.is_integer() describes its purpose, and
mentions that it should be overridden for performance reasons, or
to handle special values like NaN.

* bpo-26680: Adds Decimal.is_integer to the Python and C implementations.

The C implementation of Decimal already implements and uses
mpd_isinteger internally, we just expose the existing function to
Python.

The Python implementation uses internal conversion to integer
using to_integral_value().

In both cases, the corresponding context methods are also
implemented.

Tests and documentation are included.

* bpo-26680: Updates the ACKS file.

* bpo-26680: NEWS entries for int, the numeric ABCs and Decimal.

Co-authored-by: Robert Smallshire <rob@sixty-north.com>
2020-10-01 17:30:08 +01:00
..
asyncio bpo-39651: Fix asyncio proactor _write_to_self() (GH-22197) 2020-09-12 08:50:18 +02:00
collections Revert "Fix all Python Cookbook links (#22205)" (GH-22424) 2020-09-27 01:47:25 +01:00
concurrent bpo-39349: Add cancel_futures to Executor.shutdown base class (GH-22023) 2020-09-01 17:18:07 -04:00
ctypes bpo-40275: Remove test helpers aliases in test.support (GH-21771) 2020-08-08 11:32:41 +02:00
curses
dbm
distutils bpo-41207 In distutils.spawn, rewrite FileNotFound (GH-21359) 2020-07-07 04:11:28 -07:00
email bpo-40597: Allow email.contextmanager set_content() to set a null string. (GH-20542) 2020-07-08 14:00:35 -07:00
encodings
ensurepip bpo-38488: Upgrade bundled versions of pip & setuptools (GH-20491) 2020-06-15 15:16:48 -04:00
html
http bpo-39603: Prevent header injection in http methods (GH-18485) 2020-07-18 13:16:10 -07:00
idlelib bpo-41775: Make 'IDLE Shell' the shell title (#22399) 2020-09-24 15:30:09 -04:00
importlib bpo-40924: Ensure importlib.resources.path returns an extant path (GH-20857) 2020-06-29 22:59:22 +02:00
json
lib2to3
logging Fix logging error message (GH-22410) 2020-09-25 11:08:50 -07:00
msilib
multiprocessing bpo-41344: Raise ValueError when creating shared memory of size 0 (GH-21556) 2020-08-30 20:03:11 +01:00
pydoc_data
site-packages
sqlite3 bpo-41815: SQLite: segfault if backup called on closed database (GH-22322) 2020-09-19 20:40:46 -07:00
test bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121) 2020-10-01 17:30:08 +01:00
tkinter bpo-41817: use new StrEnum to ensure all members are strings (GH-22348) 2020-09-22 08:01:17 -07:00
turtledemo
unittest bpo-40275: Use new test.support helper submodules in tests (GH-21449) 2020-08-03 18:41:24 +02:00
urllib
venv bpo-35328: Set VIRTUAL_ENV_PROMPT at venv activation (GH-21587) 2020-07-28 09:41:57 +01:00
wsgiref
xml bpo-35018: Sax parser should provide user access to lexical handlers (GH-20958) 2020-08-09 12:50:53 +02:00
xmlrpc
zoneinfo bpo-41065: Use zip-strict in zoneinfo (GH-21031) 2020-06-23 10:21:26 -04:00
__future__.py bpo-41314: fixed annotations __future__ version (GH-21616) 2020-07-25 14:42:49 -07:00
__phello__.foo.py
_aix_support.py
_bootlocale.py
_bootsubprocess.py
_collections_abc.py
_compat_pickle.py
_compression.py
_markupbase.py bpo-31844: Remove _markupbase.ParserBase.error() (GH-8562) 2020-07-16 09:13:05 +03:00
_osx_support.py
_py_abc.py
_pydecimal.py bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121) 2020-10-01 17:30:08 +01:00
_pyio.py
_sitebuiltins.py
_strptime.py
_threading_local.py
_weakrefset.py
abc.py
aifc.py
antigravity.py
argparse.py
ast.py bpo-41631: _ast module uses again a global state (#21961) 2020-09-15 18:03:34 +02:00
asynchat.py
asyncore.py
base64.py bpo-16995: add support for base32 extended hex (base32hex) (GH-20441) 2020-08-10 07:48:20 -07:00
bdb.py
binhex.py
bisect.py Fix error in docstrings in bisect module (GH-21422) 2020-07-11 20:18:31 -03:00
bz2.py
calendar.py
cgi.py bpo-34226: fix cgi.parse_multipart without content_length (GH-8530) 2020-06-15 07:58:54 -07:00
cgitb.py
chunk.py
cmd.py
code.py
codecs.py bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822) 2020-08-11 06:26:59 -07:00
codeop.py bpo-41520: Fix second codeop regression (GH-21848) 2020-08-13 13:18:49 -04:00
colorsys.py
compileall.py
configparser.py
contextlib.py
contextvars.py
copy.py
copyreg.py
cProfile.py
crypt.py
csv.py
dataclasses.py Fix typo in dataclasses module (GH-21109) 2020-06-24 03:46:52 -07:00
datetime.py
decimal.py
difflib.py
dis.py bpo-41497: Fix potential UnicodeDecodeError in dis CLI (GH-21757) 2020-08-08 12:03:09 +09:00
doctest.py
enum.py bpo-41816: StrEnum.__str__ is str.__str__ (GH-22362) 2020-09-22 13:00:07 -07:00
filecmp.py
fileinput.py
fnmatch.py
formatter.py
fractions.py
ftplib.py
functools.py bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796) 2020-06-28 15:40:54 +09:00
genericpath.py
getopt.py
getpass.py
gettext.py
glob.py bpo-38144: Add the root_dir and dir_fd parameters in glob.glob(). (GH-16075) 2020-06-18 22:08:27 +03:00
graphlib.py
gzip.py
hashlib.py Improve blake2 comment for Victor (GH-20981) 2020-06-19 07:11:02 -07:00
heapq.py Revert "Fix all Python Cookbook links (#22205)" (GH-22424) 2020-09-27 01:47:25 +01:00
hmac.py
imaplib.py
imghdr.py bpo-41043: Escape literal part of the path for glob(). (GH-20994) 2020-06-20 11:10:31 +03:00
imp.py
inspect.py
io.py
ipaddress.py bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822) 2020-08-11 06:26:59 -07:00
keyword.py Delete remaining references to Grammar/Grammar from docs (#21624) 2020-07-26 08:27:52 -07:00
linecache.py
locale.py
lzma.py
mailbox.py
mailcap.py
mimetypes.py bpo-41048: mimetypes should read the rule file using UTF-8, not the locale encoding (GH-20998) 2020-06-29 11:36:48 +03:00
modulefinder.py
netrc.py
nntplib.py
ntpath.py
nturl2path.py
numbers.py bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121) 2020-10-01 17:30:08 +01:00
opcode.py
operator.py
optparse.py
os.py
pathlib.py bpo-33660: Fix PosixPath to resolve a relative path on root 2020-08-27 02:24:38 +02:00
pdb.py bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) 2020-08-27 02:51:12 +02:00
pickle.py
pickletools.py
pipes.py
pkgutil.py bpo-41006: pkgutil imports lazily re (GH-20939) 2020-06-17 19:11:50 +02:00
platform.py
plistlib.py
poplib.py
posixpath.py
pprint.py bpo-39994: Fix pprint handling of dict subclasses that override __repr__ (GH-21892) 2020-08-30 20:29:53 +03:00
profile.py
pstats.py bpo-41811: create SortKey members using first given value (GH-22316) 2020-09-19 11:12:57 -07:00
pty.py
py_compile.py bpo-38731: Add --quiet option to py_compile CLI (GH-17134) 2020-07-25 22:58:45 +03:00
pyclbr.py
pydoc.py
queue.py
quopri.py
random.py bpo-41773: Raise exception for non-finite weights in random.choices(). (GH-22441) 2020-09-28 18:32:10 -07:00
re.py
reprlib.py
rlcompleter.py bpo-39314: Closes parenthesis when autocompleting for functions that take no arguments (GH-20562) 2020-06-30 22:48:15 +09:00
runpy.py
sched.py
secrets.py
selectors.py bpo-41182 selector: use DefaultSelector based upon implementation (GH-21257) 2020-07-22 20:13:37 -07:00
shelve.py
shlex.py
shutil.py
signal.py
site.py bpo-33689: Blank lines in .pth file cause a duplicate sys.path entry (GH-20679) 2020-09-19 22:13:29 +03:00
smtpd.py
smtplib.py
sndhdr.py bpo-41043: Escape literal part of the path for glob(). (GH-20994) 2020-06-20 11:10:31 +03:00
socket.py
socketserver.py
sre_compile.py
sre_constants.py
sre_parse.py
ssl.py
stat.py
statistics.py Some reformatting (suggested by Black) and minor factoring. (GH-20865) 2020-06-13 19:17:28 -07:00
string.py
stringprep.py
struct.py
subprocess.py
sunau.py
symtable.py bpo-41224: Document is_annotated() in symtable module and update doc strings (GH-21369) 2020-07-07 20:09:56 -03:00
sysconfig.py bpo-41627: Distinguish 32 and 64-bit user site packages on Windows (GH-22098) 2020-09-05 00:45:54 +01:00
tabnanny.py
tarfile.py bpo-41316: Make tarfile follow specs for FNAME (GH-21511) 2020-09-07 09:46:33 -07:00
telnetlib.py
tempfile.py bpo-41410: Fix outdated info in mkstemp docs (GH-21701) 2020-08-13 18:33:14 -07:00
textwrap.py
this.py
threading.py bpo-41833: threading.Thread now uses the target name (GH-22357) 2020-09-23 23:21:19 +02:00
timeit.py bpo-40670: More reliable validation of statements in timeit.Timer. (GH-22358) 2020-09-22 16:16:46 +03:00
token.py
tokenize.py
trace.py bpo-41138: Fix trace CLI for non-UTF-8 files. (GH-21177) 2020-06-28 13:34:22 +03:00
traceback.py
tracemalloc.py
tty.py
turtle.py bpo-41720: Add "return NotImplemented" in turtle.Vec2D.__rmul__(). (GH-22092) 2020-09-07 18:55:22 +03:00
types.py bpo-41810: Reintroduce types.EllipsisType, .NoneType & .NotImplementedType (GH-22336) 2020-09-22 08:55:34 -07:00
typing.py bpo-41792: Add is_typeddict function to typing.py (GH-22254) 2020-09-15 21:58:32 -07:00
uu.py
uuid.py bpo-41364: Reduce import overhead of uuid module (GH-21586) 2020-07-22 00:15:47 +01:00
warnings.py
wave.py
weakref.py
webbrowser.py bpo-41005: Fixed perrmission error (GH-20936) 2020-06-22 11:06:07 +02:00
xdrlib.py
zipapp.py
zipfile.py bpo-40105: ZipFile truncate in append mode with shorter comment (GH-19337) 2020-09-28 21:53:33 +03:00
zipimport.py